view light8/Patch.py @ 51:71489bb71528

- Meet Fader. He is going to grow up and be a crossfader some day - Meet Fader. He is going to grow up and be a crossfader some day (tomarrow) - Tkinter -> Tix so we can use ScrolledListBox which has a command - Some improvements to Cue - Cues need to specify their final values - Cues are imported by subs. This should be fixed for style points. - Some other cleanups
author dmcc
date Sun, 07 Jul 2002 15:40:45 +0000
parents 5e4fb4ac2d18
children 174b35926067
line wrap: on
line source

from types import TupleType

def get_dmx_channel(name):
    if name in patch:
        return patch[name]

    try:
        i = int(name)
        return i
    except ValueError:
        raise ValueError("Invalid channel name: %s" % name)

def get_channel_name(dmxnum):
    try:
        return reverse_patch[dmxnum]
    except KeyError:
        return str(dmxnum)

def reload_data(dummy):
    global patch, reverse_patch
    if dummy:
        import ConfigDummy as Config
    else:
        import Config

    reload(Config)
    loadedpatch = Config.patch
    patch = {}
    reverse_patch = {}
    for k, v in loadedpatch.items():
        if type(k) == TupleType:
            for name in k:
                patch[name] = v
            reverse_patch[v] = k[0]
        else:
            patch[k] = v
            reverse_patch[v] = k