def create_voices(self): voice_ids = ['1', '2', '3', '4'] SCALES = OrderedDict([ ('pan_pos', {'min': -1, 'max': 1, 'start': 0.5, 'res': 0.001}), ('volume', {'min': 0, 'max': 1, 'start': 0.666, 'res': 0.001}), ('slide_duration_msecs', {'min': 0, 'max': 2000, 'start': 60, 'res': 1}), ('slide_duration_prop', {'min': 0, 'max': 2, 'start': 0.666, 'res': 0.001}), ('binaural_diff', {'min': 0, 'max': 66, 'start': 0.2, 'res': 0.01}) ]) for vid in voice_ids: counter = 0 for sca in SCALES: name = 'voice_' + vid + '_' + sca setattr(self, 'min_' + name, SCALES[sca]['min']) setattr(self, 'max_' + name, SCALES[sca]['max']) this_sca = Scale(self, label=sca, orient=HORIZONTAL, from_=getattr(self, 'min_' + name), to=getattr(self, 'max_' + name), resolution=SCALES[sca]['res']) this_sca.enable = ('enable' in SCALES[sca].keys() and SCALES[sca]['enable'] or None) this_sca.disable = ('disable' in SCALES[sca].keys() and SCALES[sca]['disable'] or None) this_sca.grid(column=int(2 + int(vid)), row=counter, sticky=E + W) this_sca.bind("<ButtonRelease>", self.scale_handler) this_sca.ref = name counter += 1 CHECK_BUTTONS = OrderedDict( [('mute', False), ('automate_binaural_diffs', True), ('automate_note_duration_prop', True), ('use_proportional_slide_duration', {'val': True, 'label': 'proportional slide'}), ('automate_pan', True), ('automate_wavetables', True)]) for vid in voice_ids: counter = 0 cb_frame = LabelFrame(self, text="Voice {0} - Automation".format(vid)) setattr(self, 'voice_' + vid + '_cb_frame', cb_frame) for cb in CHECK_BUTTONS: options = CHECK_BUTTONS[cb] name = 'voice_' + vid + '_' + cb label = (options['label'] if isinstance(options, dict) and 'label' in options.keys() else (cb[9:] if cb[:9] == 'automate_' else cb)) setattr(self, name, IntVar(value=type(options) == dict and options['val'] or options)) self.this_cb = Checkbutton(cb_frame, text=label, variable=getattr(self, name)) self.this_cb.bind('<Button-1>', self.check_boxes_handler) self.this_cb.disable = None self.this_cb.grid(sticky=W, column=0, row=counter) self.this_cb.ref = name counter += 1 # add trigger wavetable-button trigWavetableButton = Button(cb_frame, text='Next Wavetable') trigWavetableButton.bind('<Button-1>', self.trigger_waveform_handler) trigWavetableButton.ref = 'voice_' + vid + "_trigger_wavetable" trigWavetableButton.grid(row=counter) cb_frame.grid(column=int(vid) + 2, row=5, sticky=E + W + N, rowspan=8) for vid in voice_ids: generation_types = ["random", "random_harmonic", "harmonic"] partial_pools = ["even", "odd", "all"] prefix = 'voice_' + vid + '_' types_name = prefix + 'wavetable_generation_type' pools_name = prefix + 'partial_pool' setattr(self, types_name, StringVar()) getattr(self, types_name).set("random") setattr(self, pools_name, StringVar()) getattr(self, pools_name).set("all") target_frame = getattr(self, 'voice_' + vid + '_cb_frame') gen_typ_frame = LabelFrame(target_frame, text="type") gen_typ_frame.grid(row=len(target_frame.winfo_children()), sticky=W) for gen_t in generation_types: gen_t_entry = Radiobutton(gen_typ_frame, value=gen_t, text=gen_t, anchor=W, variable=getattr(self, types_name)) gen_t_entry.bind('<ButtonRelease-1>', self.wt_handler) gen_t_entry.ref = types_name gen_t_entry.grid(row=len(gen_typ_frame.winfo_children()), sticky=W) pp_frame = LabelFrame(target_frame, text="harmonics") for pp in partial_pools: pp_entry = Radiobutton(pp_frame, value=pp, text=pp, anchor=W, variable=getattr(self, pools_name)) pp_entry.bind('<ButtonRelease-1>', self.wt_handler) pp_entry.ref = pools_name pp_entry.grid(row=len(pp_frame.winfo_children()), sticky=E + W) this_num_partials = Scale(pp_frame, label='number of harmonics', orient=HORIZONTAL, from_=1, to=24, resolution=1) this_num_partials.ref = prefix + 'num_partials' this_num_partials.grid(column=0, row=len(pp_frame.winfo_children()), sticky=E + W) this_num_partials.bind("<ButtonRelease>", self.scale_handler) pp_frame.grid(row=len(target_frame.winfo_children()), sticky=E + W)
def create_check_buttons(self): self.cb_frame = LabelFrame(self, text="Global Settings") for cb in CHECK_BUTTONS: label = cb target_parent = self.cb_frame if isinstance(CHECK_BUTTONS[cb], dict) and 'sub_frame' in CHECK_BUTTONS[cb].keys(): target_parent = getattr(self, CHECK_BUTTONS[cb]['sub_frame']) setattr(self, cb, IntVar(value=type(CHECK_BUTTONS[cb]) == dict and CHECK_BUTTONS[cb]['val'] or CHECK_BUTTONS[cb])) self.this_cb = Checkbutton(target_parent, text=label, variable=getattr(self, cb)) self.this_cb.bind('<Button-1>', self.check_boxes_handler) self.this_cb.disable = (type(CHECK_BUTTONS[cb]) == dict and 'disable' in CHECK_BUTTONS[cb].keys()) self.this_cb.grid(sticky=W, column=0, row=len(target_parent.winfo_children())) self.this_cb.ref = cb for but in GLOBAL_BUTTONS: label = but ele = GLOBAL_BUTTONS[but] this_but = Button(self.cb_frame, text=but) this_but.bind('<ButtonRelease-1>', getattr(self, ele['handler'])) this_but.ref = but this_but.grid(sticky=W, column=0, row=len(self.cb_frame.winfo_children())) self.cb_frame.grid(column=0, row=0, rowspan=10, sticky=N)
def __init__(self, parent, wdir, tooltipwidth, ehThis, ehFromHere): """Initiate Arguments parent -- parent tkinter item wdir -- working directory tooltipwidth -- maximum width of the tooltip ehThis -- callback for playing one frame ehFromHere -- callback for playing the rest of the frames from a given position """ IndexedFrame.__init__(self, parent) self._wdir = wdir self._il = None self._parent = parent self._lblFrame = StringVar() self._lblImagename = StringVar() self._lblImagenamefull = StringVar() self._lblSoundname = StringVar() self._lblSoundnamefull = StringVar() self._fullSoundName = '' content = self._content content.columnconfigure(0, weight = 1) content.columnconfigure(1, weight = 1) content.rowconfigure(0, weight = 1) content.rowconfigure(1, weight = 1) content.rowconfigure(2, weight = 1) #Left group box lf = ttk.LabelFrame(content) self._lfSlide = lf lf.grid(row = 0, column = 0, sticky = W + N + E + S, padx = 5) button = Button(lf, text = lang[lng.txtPlayThisFrame] + '...', command = lambda arg=self: ehThis(arg)) button.grid(row = 1, column = 0, sticky = W + E, padx = 5, pady = 5) button = Button(lf, text = lang[lng.txtPlayFromHere] + '...', command = lambda arg=self: ehFromHere(arg)) button.grid(row = 2, column = 0, sticky = W + E, padx = 5, pady = 5) #Image group box lf = ttk.LabelFrame(content, text = ' ' + lang[lng.txtImage] + ' ') lf.grid(row = 0, column = 1, padx = 5, sticky = W + N + E + S) label = Label(lf, textvariable = self._lblImagename, justify = LEFT) label.grid(row = 0, column = 1, padx = 5, pady = 5, sticky = W) tt = ToolTip(label, '', textvariable = self._lblImagenamefull, wraplength = tooltipwidth) button = Button(lf, text = lang[lng.txtSelect] + '...', command = self._ehGetImage) button.grid(row = 0, column = 0, sticky = W, padx = 5, pady = 5) button.ref = self imFrame = Frame(lf) self._imageFrame = imFrame imFrame['width'] = _previewWidth imFrame['height'] = _previewHeight imFrame.grid(row = 1, column = 1, padx = 5, pady = 5) imFrame.grid_propagate(0) lf = ttk.Labelframe(content, text = ' ' + lang[lng.txtSound] + ' ') lf.grid(row = 0, column = 2, padx = 5, sticky = W + N + E + S) #Sound group box label = Label(lf, textvariable = self._lblSoundname) label.grid(row = 0, column = 0, padx = 5, pady = 5, sticky = W, columnspan = 10) tt = ToolTip(label, '', textvariable = self._lblSoundnamefull, wraplength = tooltipwidth) button = SoundButton(lf, lang[lng.txtListen], lang[lng.txtStop], self._clbPlaying) self._btnSound = button button.grid(row = 1, column = 0, sticky = W + E, padx = 5, pady = 5) button = Button(lf, text = lang[lng.txtSelect] + '...', command = self._ehGetSound) button.grid(row = 2, column = 0, sticky = W + E, padx = 5, pady = 5) self._btnSelect = button button = Button(lf, text = lang[lng.txtDelete], state = DISABLED, command = self._ehRemoveSound) button.grid(row = 3, column = 0, sticky = W + E, padx = 5, pady = 5) self._btnRemove = button fr = Frame(lf, width = 160) fr.grid(row = 4, column = 0, columnspan = 10)