def _edit_remarks(self): bnk = self.synth.bank() name = bnk.name filename = bnk.filename remarks = bnk.remarks dialog = Toplevel(self) frame = factory.frame(dialog, True) frame.pack(expand=True, fill="both") lab_title = factory.center_label(frame, "Bank Info") lab_name = factory.label(frame, "Bank name : '%s'" % name) lab_filename = factory.label(frame, "Filename : '%s'" % filename) frame_text = factory.label_frame(frame, "Remarks") lab_title.grid(row=0, column=0, columnspan=3,pady=12) lab_name.grid(row=1, column=0, sticky="w", padx=4) lab_filename.grid(row=2, column=0, sticky="w", padx=4) frame_text.grid(row=3, column=0, columnspan=3, padx=4, pady=8) text_widget = factory.text_widget(frame_text, "Bank remarks") text_widget.insert('end', remarks) text_widget.config(width=80, height=20) vsb = factory.scrollbar(frame_text, orientation="vertical") hsb = factory.scrollbar(frame_text, orientation="horizontal") text_widget.grid(row=0, column=0, rowspan=8, columnspan=8, ipadx=4, ipady=4) vsb.grid(row=0, column=8, rowspan=8, columnspan=1, sticky="ns") hsb.grid(row=8, column=0, rowspan=1, columnspan=8, sticky="ew") vsb.config(command=text_widget.yview) hsb.config(command=text_widget.xview) text_widget.config(yscrollcommand=vsb.set) text_widget.config(xscrollcommand=hsb.set) frame_toolbar = factory.frame(frame, True) frame_toolbar.grid(row=4, column=0, padx=4, pady=8) def clear(): text_widget.delete(1.0, 'end') def accept(): rem = text_widget.get(1.0, 'end') bnk.remarks = rem self.status("Bank remarks updated") dialog.destroy() def cancel(): self.status("Change bank remarks canceld") dialog.destroy() b_clear = factory.clear_button(frame_toolbar, command=clear, ttip="Clear remarks") b_accept = factory.accept_button(frame_toolbar, command=accept) b_cancel = factory.cancel_button(frame_toolbar, command=cancel) b_clear.grid(row=0, column=0, padx=4, pady=8) b_accept.grid(row=0, column=1) b_cancel.grid(row=0, column=2) dialog.grab_set() dialog.mainloop()
def __init__(self, master, app): Frame.__init__(self, master) self.config(background=factory.bg()) self.app = app self.proxy = app.proxy self.pack_propagate(False) self.listbox = factory.listbox(self) self.listbox.config(width=75, height=20) sbv = factory.scrollbar(self, yclient=self.listbox) sbh = factory.scrollbar(self, xclient=self.listbox, orientation=HORIZONTAL) self.listbox.grid(row=0, column=0, rowspan=6, columnspan=8) sbv.grid(row=0, column=8, rowspan=6, sticky=NS) sbh.grid(row=6, column=0, columnspan=8, sticky=EW) self.refresh()
def __init__(self, master, app): Toplevel.__init__(self, master) self.config(background=factory.bg()) self.wm_title("Lliascript History") self.app = app self.filename = "" toolbar = factory.frame(self) south = factory.frame(self) toolbar.pack(side=TOP, anchor=NW, expand=True, fill=X) south.pack(anchor=SW, expand=True, fill=BOTH) b_open = factory.button(toolbar, "Open", ttip="Open lliascript file", command=self.open_lliascript_file) b_save = factory.button(toolbar, "Save", ttip="Save lliascript file", command=self.save_lliascript_file) b_exec = factory.button(toolbar, "Exec", ttip="Execute text", command=self.exec_) b_compose = factory.button(toolbar, "Compose", ttip="Build script from current state", command=self.compose_current_state) b_help = factory.help_button(toolbar) b_help.config(command=self.help_) b_open.pack(side=LEFT, expand=True, fill=X) b_save.pack(side=LEFT, expand=True, fill=X) b_exec.pack(side=LEFT, expand=True, fill=X) b_compose.pack(side=LEFT, expand=True, fill=X) b_help.pack(side=LEFT, expand=True, fill=X) self.text_widget = factory.text_widget(south, modal=True) sb1 = factory.scrollbar(south) sb2 = factory.scrollbar(south, orientation="horizontal") sb1.config(command=self.text_widget.yview) sb2.config(command=self.text_widget.xview) self.text_widget.config(yscrollcommand=sb1.set) self.text_widget.config(xscrollcommand=sb2.set) self.text_widget.grid(row=0, column=0, rowspan=5, columnspan=5) sb1.grid(row=0, column=5, rowspan=5, sticky=NS) sb2.grid(row=5, column=0, columnspan=5, sticky=EW) self._get_current_history() self.grab_set() self.mainloop()
def __init__(self, master, app): Toplevel.__init__(self, master) self.wm_title = "Control Buses" self.app = app self.proxy = app.proxy self.parser = app.ls_parser main = factory.frame(self, modal=True) main.pack(expand=True) lab_title = factory.label(main, "Control Busses", modal=True) frame_list = factory.frame(main, modal=True) frame_list.config(width=248, height=320) frame_list.pack_propagate(False) self.listbox = factory.listbox(frame_list, command=self.select_bus) self.listbox.pack(expand=True, fill=BOTH) sb = factory.scrollbar(main, yclient=self.listbox) lab_name = factory.label(main, "Name", modal=True) lab_channels = factory.label(main, "Channels", modal=True) self._var_name = StringVar() entry_name = factory.entry(main, self._var_name, ttip="Control bus name") #self._var_chancount = StringVar() #spin_chancount = factory.int_spinbox(main, self._var_chancount, 1, 64) self.lab_warning = factory.warning_label(main, modal=True) button_bar = factory.frame(main, modal=True) #b_remove = factory.delete_button(button_bar,ttip="Delete control bus",command=self.remove_bus) b_add = factory.add_button(button_bar, ttip="Add new control bus", command=self.add_bus) #b_refresh = factory.refresh_button(button_bar, ttip="Refresh bus list", command=self.refresh) b_accept = factory.accept_button(button_bar, command=self.accept) b_help = factory.help_button(button_bar, command=self.display_help) lab_title.grid(row=0, column=0, columnspan=6, pady=8) frame_list.grid(row=1, column=0, rowspan=5, columnspan=5, pady=8) sb.grid(row=1, column=4, rowspan=5, sticky=NS, pady=4, padx=4) lab_name.grid(row=6, column=0, sticky=W, padx=4) entry_name.grid(row=6, column=1) lab_channels.grid(row=7, column=0, sticky=W, pady=8, padx=4) #spin_chancount.grid(row=7, column=1) self.lab_warning.grid(row=8, column=0, columnspan=6) button_bar.grid(row=9, column=0, columnspan=6, padx=8, pady=4) #b_remove.grid(row=0, column=0) b_add.grid(row=0, column=1) #b_refresh.grid(row=0, column=2) b_help.grid(row=0, column=3) #factory.label(button_bar, "").grid(row=0, column=4, padx=16) factory.padding_label(button_bar).grid(row=0, column=4, padx=16) b_accept.grid(row=0, column=5) self._current_selection = 0 entry_name.bind('<Down>', self.increment_selection) entry_name.bind('<Up>', self.decrement_selection) entry_name.bind('<Return>', self.add_bus) self.listbox.bind('<Down>', self.increment_selection) self.listbox.bind('<Up>', self.decrement_selection) self.refresh() self.grab_set() self.mainloop()
def _init_list_frame(self): frame = factory.frame(self) lbx = factory.listbox(frame) sbar = factory.scrollbar(frame, orientation="vertical") lbx.pack(side="left", expand=True, fill="both") sbar.pack(after=lbx, side="right", expand=True, fill="y") lbx.config(yscrollcommand=sbar.set) lbx.bind("<<ListboxSelect>>", self._select_slot) lbx.bind("<Up>", self._decrement_selection) lbx.bind("<Down>", self._increment_selection) sbar.config(command = lbx.yview) self.listbox = lbx return frame
def __init__(self, master, app): Toplevel.__init__(self, master) self.config(background=factory.bg()) self.wm_title("Lliascript History") self.app = app self.filename = "" toolbar = factory.frame(self) south = factory.frame(self) toolbar.pack(side=TOP, anchor=NW, expand=True, fill=X) south.pack(anchor=SW, expand=True, fill=BOTH) b_open = factory.button(toolbar, "Open", ttip="Open lliascript file", command=self.open_lliascript_file) b_save = factory.button(toolbar, "Save", ttip="Save lliascript file", command=self.save_lliascript_file) b_exec = factory.button(toolbar, "Exec", ttip="Execute text", command=self.exec_) b_compose = factory.button(toolbar, "Compose", ttip="Build script from current state", command=self.compose_current_state) b_help = factory.help_button(toolbar) b_help.config(command=self.help_) b_open.pack(side=LEFT, expand=True, fill=X) b_save.pack(side=LEFT, expand=True, fill=X) b_exec.pack(side=LEFT, expand=True, fill=X) b_compose.pack(side=LEFT, expand=True, fill=X) b_help.pack(side=LEFT, expand=True, fill=X) self.text_widget = factory.text_widget(south, modal=True) sb1 = factory.scrollbar(south) sb2 = factory.scrollbar(south, orientation="horizontal") sb1.config(command=self.text_widget.yview) sb2.config(command=self.text_widget.xview) self.text_widget.config(yscrollcommand = sb1.set) self.text_widget.config(xscrollcommand = sb2.set) self.text_widget.grid(row=0, column=0, rowspan=5, columnspan=5) sb1.grid(row=0, column=5, rowspan=5, sticky=NS) sb2.grid(row=5, column=0, columnspan=5, sticky=EW) self._get_current_history() self.grab_set() self.mainloop()
def _init_info_tab(self, master): img = factory.image("resources/Tabs/info.png") frame = factory.frame(master) inner_frame = factory.frame(frame) master.add(frame, text="Info", image=img,compound="top") text_widget = factory.text_widget(inner_frame) text_widget.config(width=90, height=40) vsb = factory.scrollbar(inner_frame, orientation='vertical') vsb.config(command=text_widget.yview) hsb = factory.scrollbar(inner_frame, orientation='horizontal') hsb.config(command=text_widget.xview) text_widget.config(yscrollcommand=vsb.set, xscrollcommand=hsb.set, wrap='word',) text_widget.grid(row=0, column=0, rowspan=8, columnspan=8) vsb.grid(row=0, column=9, rowspan=8, columnspan=1, sticky='ns') hsb.grid(row=9, column=0, rowspan=1, columnspan=8, stick='we') inner_frame.grid(row=0, column=0, rowspan=8, columnspan=8) b_update = factory.button(frame, "Update", command=self.sync_program_tab) b_update.grid(row=9, column=0, sticky='ew', pady=8) b_remove = factory.button(frame, "Remove Synth", command=self.remove_synth) b_remove.grid(row=9, column=1, sticky='ew', pady=8) self._info_text_widget = text_widget
def _init_info_tab(self, master): img = factory.image("resources/Tabs/info.png") frame = factory.frame(master) inner_frame = factory.frame(frame) master.add(frame, text="Info", image=img,compound="top") text_widget = factory.text_widget(inner_frame) text_widget.config(width=120, height=40) vsb = factory.scrollbar(inner_frame, orientation='vertical') vsb.config(command=text_widget.yview) text_widget.config(yscrollcommand=vsb.set, wrap='word',) text_widget.grid(row=0, column=0,sticky="ewns") vsb.grid(row=0, column=1, sticky='ns') inner_frame.grid(row=0, column=0, rowspan=8, columnspan=8, sticky="ewns") self._info_text_widget = text_widget
def __init__(self, master, app): Toplevel.__init__(self, master) self.config(background=factory.pallet("DIALOG-BG")) self.wm_title = "MIDI Controllers" self.app = app self.config = app.config() self.parser = app.ls_parser self._current_controller=0 self._save_backup() main = factory.frame(self, modal=True) main.pack(expand=True) main.pack_propagate(False) lab_title = factory.label(main, "MIDI Controller Names", modal=True) self.lab_warning = factory.warning_label(main, "", modal=True) frame_list = factory.frame(main, modal=True) frame_list.config(width=248, height=320) frame_list.pack_propagate(False) self.listbox = factory.listbox(frame_list, command=self.select_controller) self.listbox.pack(expand=True, fill=BOTH) sb = factory.scrollbar(main, yclient=self.listbox) self.refresh() self.var_name = StringVar() entry_name = factory.entry(main, self.var_name) button_bar = factory.frame(main, modal=True) b_refresh = factory.refresh_button(button_bar, command=self.refresh) b_help = factory.help_button(button_bar, command = self.display_help) b_accept = factory.accept_button(button_bar, command=self.accept) b_cancel = factory.cancel_button(button_bar, command=self.cancel) lab_title.grid(row=0, column=0, columnspan=4, pady=8) frame_list.grid(row=1, column=0, rowspan=6, columnspan=4, sticky=N) sb.grid(row=1, column=4, rowspan=6, sticky=NS, padx=4) factory.label(main, "Name", modal=True).grid(row=7, column=0, padx=4, sticky="w") entry_name.grid(row=7, column=1, columnspan=1, sticky=W, padx=4, pady=8) self.lab_warning.grid(row=8, column=0, columnspan=5, sticky=W) button_bar.grid(row=9, column=0, columnspan=5, sticky=EW, padx=4, pady=4) b_refresh.grid(row=0, column=0) b_help.grid(row=0, column=1) b_accept.grid(row=0, column=2) b_cancel.grid(row=0, column=3) entry_name.bind('<Return>', self.change_name) entry_name.bind('<Down>', self.increment_selection) entry_name.bind('<Up>', self.decrement_selection) self.listbox.bind('<Down>', self.increment_selection) self.listbox.bind('<Up>', self.decrement_selection) self.protocol("WM_DELETE_WINDOW", None) self.grab_set() self.mainloop()
def _init_list_frame(self): frame = factory.frame(self) lbx = factory.listbox(frame) sbar = factory.scrollbar(frame, orientation="vertical") # lbx.pack(side="left", expand=True, fill="both") # sbar.pack(after=lbx, side="right", expand=True, fill="y") lbx.config(yscrollcommand=sbar.set) lbx.bind("<<ListboxSelect>>", self._select_slot) lbx.bind("<Up>", self._decrement_selection) lbx.bind("<Down>", self._increment_selection) sbar.config(command = lbx.yview) self.listbox = lbx self.cbExtend = factory.checkbutton(frame,"Extend",self._var_extend_enable, command = self._cbextended_callback) self.sbExtend = factory.int_spinbox(frame,self._var_extend_count, from_=0,to=self.synth.voice_count, command = self._sbextended_callback) self.sbExtend.config(width=2) lbx.grid(row=0,column=0,rowspan=3,columnspan=2,sticky="ewns") sbar.grid(row=0,column=2,rowspan=3,columnspan=1,sticky="ns") if self.synth.keymode in constants.SUPPORTS_EXTENDED_PROGRAMS: self.cbExtend.grid(row=3,column=0,stick="w",pady=4,padx=4) self.sbExtend.grid(row=3,column=1,sticky='w') return frame
def _init_map2_tab(self, master): img = factory.image("resources/Tabs/map.png") HELP_TOPIC = "parameter-maps" HEIGHT = 8 frame = factory.frame(master) master.add(frame, text="Map2",image=img,compound="top") north = factory.label_frame(frame, "Velocity Maps") center = factory.label_frame(frame, "Aftertouch Maps") south = factory.label_frame(frame, "Keynumber Maps") north.grid(row=0, column=0, sticky="ew", padx=8, pady=8) center.grid(row=1, column=0, sticky="ew", padx=8) south.grid(row=2, column=0, sticky="ew", padx=8, pady=8) def help_callback(): self.app.main_window().display_help(HELP_TOPIC) list_vel_maps = factory.listbox(north, ttip="Active velocity maps") list_vel_maps.config(width=80, height=HEIGHT) self.list_vel_maps = list_vel_maps sb = factory.scrollbar(north, orientation="vertical") sb.config(command=list_vel_maps.yview) list_vel_maps.config(yscrollcommand=sb.set) b_add_vel = factory.add_button(north, ttip="Add velocity map") b_delete_vel = factory.delete_button(north, ttip="Delete velocity map") list_vel_maps.grid(row=0, column=0, columnspan=8, sticky="ew") sb.grid(row=0, column=8, sticky="ns") b_add_vel.grid(row=1, column=0, sticky="ew") b_delete_vel.grid(row=1, column=1, sticky="ew") list_atouch_maps = factory.listbox(center, ttip="Active after touch maps") list_atouch_maps.config(width=80, height=HEIGHT) self.list_atouch_maps = list_atouch_maps sb = factory.scrollbar(center, orientation="vertical") sb.config(command=list_atouch_maps.yview) list_atouch_maps.config(yscrollcommand=sb.set) b_add_atouch = factory.add_button(center, ttip="Add after touch map") b_delete_atouch = factory.delete_button(center, ttip="Delete after touch map") list_atouch_maps.grid(row=0, column=0, columnspan=8, sticky="ew") sb.grid(row=0, column=8, sticky="ns") b_add_atouch.grid(row=1, column=0, sticky="ew") b_delete_atouch.grid(row=1, column=1, sticky="ew") list_keynum_maps = factory.listbox(south, ttip="Active key number maps") list_keynum_maps.config(width=80, height=HEIGHT) self.list_keynum_maps = list_keynum_maps sb = factory.scrollbar(south, orientation="vertical") sb.config(command=list_keynum_maps.yview) list_keynum_maps.config(yscrollcommand=sb.set) b_add_keynum = factory.add_button(south, ttip="Add key number map") b_delete_keynum = factory.delete_button(south, ttip="Delete key number map") b_help = factory.help_button(south, command=help_callback) list_keynum_maps.grid(row=0, column=0, columnspan=8, sticky="ew") sb.grid(row=0, column=8, sticky="ns") b_add_keynum.grid(row=1, column=0, sticky="ew") b_delete_keynum.grid(row=1, column=1, sticky="ew") b_help.grid(row=1, column=7, sticky="ew") def add_map_callback(event): widget = event.widget if widget is b_add_vel: dialog = add_map_dialog(self.synth, "velocity", self.app) elif widget is b_add_atouch: dialog = add_map_dialog(self.synth, "aftertouch", self.app) elif widget is b_add_keynum: dialog = add_map_dialog(self.synth, "keynumber", self.app) else: msg = "Invald widget - Should never see this" raise ValueError(msg) def delete_map_callback(event): widget = event.widget if widget is b_delete_vel: dialog = delete_map_dialog(self, self.synth, "velocity", self.app) elif widget is b_delete_atouch: dialog = delete_map_dialog(self, self.synth, "aftertouch", self.app) elif widget is b_delete_keynum: dialog = delete_map_dialog(self, self.synth, "keynumber", self.app) else: msg = "Invald widget - Should never see this" raise ValueError(msg) b_add_vel.bind("<Button-1>", add_map_callback) b_add_atouch.bind("<Button-1>", add_map_callback) b_add_keynum.bind("<Button-1>", add_map_callback) b_delete_vel.bind("<Button-1>", delete_map_callback) b_delete_atouch.bind("<Button-1>", delete_map_callback) b_delete_keynum.bind("<Button-1>", delete_map_callback)
def _init_map1_tab(self, master): img = factory.image("resources/Tabs/map.png") HELP_TOPIC = "parameter-maps" frame = factory.frame(master) master.add(frame, text="Map1", image=img, compound="top") north = factory.label_frame(frame, "MIDI Controller Maps") south = factory.label_frame(frame, "Pitch Wheel Maps") north.grid(row=0, column=0, sticky="ew", padx=8, pady=8) south.grid(row=1, column=0, sticky="ew", padx=8, pady=8) def help_callback(): self.app.main_window().display_help(HELP_TOPIC) list_cc_maps = factory.listbox(north, ttip="Active MIDI controller maps") list_cc_maps.config(width=80, height=16) self.list_cc_maps = list_cc_maps sb = factory.scrollbar(north, orientation="vertical") sb.config(command=list_cc_maps.yview) list_cc_maps.config(yscrollcommand=sb.set) b_add_cc = factory.add_button(north, ttip="Add new controller map") b_delete_cc = factory.delete_button(north, ttip="Delete controller map") list_cc_maps.grid(row=0, column=0, rowspan=4, columnspan=8, sticky="ew") sb.grid(row=0, column=8, rowspan=4, sticky="ns") b_add_cc.grid(row=4, column=0, sticky="ew") b_delete_cc.grid(row=4, column=1, sticky="ew") list_pwheel_maps = factory.listbox(south, ttip="Active pitch wheel maps") list_pwheel_maps.config(width=80, height=8) self.list_pwheel_maps = list_pwheel_maps sb = factory.scrollbar(south, orientation="vertical") sb.config(command=list_pwheel_maps.yview) list_pwheel_maps.config(yscrollcommand=sb.set) b_add_pw = factory.add_button(south, ttip="Add pitchwheel map") b_delete_pw = factory.delete_button(south, ttip="Delete pitchwheel map") b_help = factory.help_button(south, command=help_callback) list_pwheel_maps.grid(row=0, column=0, rowspan=4, columnspan=8, sticky="ew") sb.grid(row=0, column=8, rowspan=4, sticky="ns") b_add_pw.grid(row=4, column=0, sticky="ew") b_delete_pw.grid(row=4, column=1, sticky="ew") b_help.grid(row=4, column=7, sticky="ew") def add_cc_callback(): dialog = add_map_dialog(self.synth, "cc", self.app) def delete_cc_callback(): dialog = delete_map_dialog(self, self.synth, "cc", self.app) def add_pw_callback(): dialog = add_map_dialog(self.synth, "PitchWheel", self.app) def delete_pw_callback(): dialog = delete_map_dialog(self, self.synth, "PitchWheel", self.app) b_add_cc.config(command=add_cc_callback) b_delete_cc.config(command=delete_cc_callback) b_add_pw.config(command=add_pw_callback) b_delete_pw.config(command=delete_pw_callback)
def _init_map2_tab(self, master): img = factory.image("resources/Tabs/map.png") HELP_TOPIC = "parameter-maps" HEIGHT = 8 frame = factory.frame(master) master.add(frame, text="Map2",image=img,compound="top") north = factory.label_frame(frame, "Velocity Maps") center = factory.label_frame(frame, "Aftertouch Maps") south = factory.label_frame(frame, "Keynumber Maps") north.grid(row=0, column=0, sticky="ew", padx=8, pady=8) center.grid(row=1, column=0, sticky="ew", padx=8) south.grid(row=2, column=0, sticky="ew", padx=8, pady=8) def help_callback(): self.app.main_window().display_help(HELP_TOPIC) list_vel_maps = factory.listbox(north, ttip="Active velocity maps") list_vel_maps.config(width=80, height=HEIGHT) self.list_vel_maps = list_vel_maps sb = factory.scrollbar(north, orientation="vertical") sb.config(command=list_vel_maps.yview) list_vel_maps.config(yscrollcommand=sb.set) b_add_vel = factory.add_button(north, ttip="Add velocity map") b_delete_vel = factory.delete_button(north, ttip="Delete velocity map") list_vel_maps.grid(row=0, column=0, columnspan=8, sticky="ew") sb.grid(row=0, column=8, sticky="ns") b_add_vel.grid(row=1, column=0, sticky="ew") b_delete_vel.grid(row=1, column=1, sticky="ew") list_atouch_maps = factory.listbox(center, ttip="Active after touch maps") list_atouch_maps.config(width=80, height=HEIGHT) self.list_atouch_maps = list_atouch_maps sb = factory.scrollbar(center, orientation="vertical") sb.config(command=list_atouch_maps.yview) list_atouch_maps.config(yscrollcommand=sb.set) b_add_atouch = factory.add_button(center, ttip="Add after touch map") b_delete_atouch = factory.delete_button(center, ttip="Delete after touch map") list_atouch_maps.grid(row=0, column=0, columnspan=8, sticky="ew") sb.grid(row=0, column=8, sticky="ns") b_add_atouch.grid(row=1, column=0, sticky="ew") b_delete_atouch.grid(row=1, column=1, sticky="ew") list_keynum_maps = factory.listbox(south, ttip="Active key number maps") list_keynum_maps.config(width=80, height=HEIGHT) self.list_keynum_maps = list_keynum_maps sb = factory.scrollbar(south, orientation="vertical") sb.config(command=list_keynum_maps.yview) list_keynum_maps.config(yscrollcommand=sb.set) b_add_keynum = factory.add_button(south, ttip="Add key number map") b_delete_keynum = factory.delete_button(south, ttip="Delete key number map") b_help = factory.help_button(south, command=help_callback) list_keynum_maps.grid(row=0, column=0, columnspan=8, sticky="ew") sb.grid(row=0, column=8, sticky="ns") b_add_keynum.grid(row=1, column=0, sticky="ew") b_delete_keynum.grid(row=1, column=1, sticky="ew") b_help.grid(row=1, column=7, sticky="ew") def add_map_callback(event): widget = event.widget if widget is b_add_vel: dialog = add_map_dialog(self.synth, "velocity", self.app) elif widget is b_add_atouch: dialog = add_map_dialog(self.synth, "aftertouch", self.app) elif widget is b_add_keynum: dialog = add_map_dialog(self.synth, "keynumber", self.app) else: msg = "Invalid widget - Should never see this" raise ValueError(msg) def delete_map_callback(event): widget = event.widget if widget is b_delete_vel: dialog = delete_map_dialog(self, self.synth, "velocity", self.app) elif widget is b_delete_atouch: dialog = delete_map_dialog(self, self.synth, "aftertouch", self.app) elif widget is b_delete_keynum: dialog = delete_map_dialog(self, self.synth, "keynumber", self.app) else: msg = "Invalid widget - Should never see this" raise ValueError(msg) b_add_vel.bind("<Button-1>", add_map_callback) b_add_atouch.bind("<Button-1>", add_map_callback) b_add_keynum.bind("<Button-1>", add_map_callback) b_delete_vel.bind("<Button-1>", delete_map_callback) b_delete_atouch.bind("<Button-1>", delete_map_callback) b_delete_keynum.bind("<Button-1>", delete_map_callback)
def _store_program(self): bnk = self.synth.bank() program = bnk[None] slot = bnk.current_slot var_name = StringVar() var_start = StringVar() var_name.set(program.name) var_start.set(slot) dialog = Toplevel() frame = factory.frame(dialog, True) frame.pack(expand=True, fill="both") lab_title = factory.label(frame, "Store Program", modal=True) lab_name = factory.label(frame, "Name", modal=True) lab_start = factory.label(frame, "Slot", modal=True) entry_name = factory.entry(frame, var_name, "Program name") spin_start = factory.int_spinbox(frame, var_start, 0, len(bnk), "Startng slot") frame_remarks = factory.label_frame(frame, "Remarks", True) text_remarks = factory.text_widget(frame_remarks, "Remarks text", modal=True) text_remarks.insert("end", program.remarks) vsb = factory.scrollbar(frame_remarks, orientation="vertical") hsb = factory.scrollbar(frame_remarks, orientation="horizontal") text_remarks.config(width=40, height=10) text_remarks.grid(row=0, column=0, rowspan=4, columnspan=4) vsb.grid(row=0, column=4, rowspan=4, sticky="ns") hsb.grid(row=4, column=0, columnspan=4, sticky="ew") vsb.config(command=text_remarks.yview) hsb.config(command=text_remarks.xview) text_remarks.config(yscrollcommand=vsb.set) text_remarks.config(xscrollcommand=hsb.set) lab_title.grid(row=0, column=0, columnspan=3, pady=8, padx=4) lab_name.grid(row=1, column=0, padx=4) entry_name.grid(row=1, column=1, columnspan=2) frame_remarks.grid(row=2, column=0, rowspan=4, columnspan=4, padx=4, pady=4) lab_start.grid(row=6, column=0, padx=4, sticky="w") spin_start.grid(row=6, column=1, columnspan=2, pady=4) b_accept = factory.accept_button(frame) b_cancel = factory.cancel_button(frame) b_accept.grid(row=8, column=1, pady=8, sticky="ew") b_cancel.grid(row=8, column=2, pady=8, sticky="ew") def accept(): try: a = int(var_start.get()) name = var_name.get() remarks = text_remarks.get(1.0, "end") program.name = name program.remarks = remarks bnk[a] = program msg = "Stored program '%s' to slots [%3d]" % (name, a) self.status(msg) dialog.destroy() self.sync() except ValueError: msg = "Invalid slot number" self.warning(msg) def cancel(): msg = "Store program canceld" self.status(msg) dialog.destroy() b_accept.config(command=accept) b_cancel.config(command=cancel) dialog.grab_set() dialog.mainloop()
def __init__(self, master, app): Toplevel.__init__(self, master) self.config(background=factory.pallet("DIALOG-BG")) self.wm_title = "MIDI Controllers" self.app = app self.config = app.config self.parser = app.ls_parser self._current_controller = 0 self._save_backup() main = factory.frame(self, modal=True) main.pack(expand=True) main.pack_propagate(False) lab_title = factory.label(main, "MIDI Controller Names", modal=True) self.lab_warning = factory.warning_label(main, "", modal=True) frame_list = factory.frame(main, modal=True) frame_list.config(width=248, height=320) frame_list.pack_propagate(False) self.listbox = factory.listbox(frame_list, command=self.select_controller) self.listbox.pack(expand=True, fill=BOTH) sb = factory.scrollbar(main, yclient=self.listbox) self.refresh() self.var_name = StringVar() entry_name = factory.entry(main, self.var_name) button_bar = factory.frame(main, modal=True) b_refresh = factory.refresh_button(button_bar, command=self.refresh) b_help = factory.help_button(button_bar, command=self.display_help) b_accept = factory.accept_button(button_bar, command=self.accept) b_cancel = factory.cancel_button(button_bar, command=self.cancel) lab_title.grid(row=0, column=0, columnspan=4, pady=8) frame_list.grid(row=1, column=0, rowspan=6, columnspan=4, sticky=N) sb.grid(row=1, column=4, rowspan=6, sticky=NS, padx=4) factory.label(main, "Name", modal=True).grid(row=7, column=0, padx=4, sticky="w") entry_name.grid(row=7, column=1, columnspan=1, sticky=W, padx=4, pady=8) self.lab_warning.grid(row=8, column=0, columnspan=5, sticky=W) button_bar.grid(row=9, column=0, columnspan=5, sticky=EW, padx=4, pady=4) b_refresh.grid(row=0, column=0) b_help.grid(row=0, column=1) b_accept.grid(row=0, column=2) b_cancel.grid(row=0, column=3) entry_name.bind('<Return>', self.change_name) entry_name.bind('<Down>', self.increment_selection) entry_name.bind('<Up>', self.decrement_selection) self.listbox.bind('<Down>', self.increment_selection) self.listbox.bind('<Up>', self.decrement_selection) self.protocol("WM_DELETE_WINDOW", None) self.grab_set() self.mainloop()
def _init_performance_tab(self, master): img = factory.image("resources/Tabs/performance.png") frame = factory.frame(master) master.add(frame, text = "Performance", image=img, compound="top") frame_channel = factory.label_frame(frame, "MIDI Channel") frame_keytab = factory.label_frame(frame, "Key Table") lab_transpose = factory.label(frame, "Transpose") lab_keyrange = factory.label(frame, "Key Range") lab_bend = factory.label(frame, "Bend Range") self.list_channel = factory.listbox(frame_channel) sb_channel = factory.scrollbar(frame_channel) sb_channel.config(command=self.list_channel.yview) self.list_channel.config(yscrollcommand=sb_channel.set) self.list_keytab = factory.listbox(frame_keytab) sb_keytab = factory.scrollbar(frame_keytab) sb_keytab.config(command=self.list_keytab.yview) self.list_keytab.config(yscrollcommand=sb_keytab.set) spin_transpose = factory.int_spinbox(frame, self.var_transpose, -36, 36) spin_keylow = factory.int_spinbox(frame, self.var_keyrange_low, 0, 127) spin_keyhigh = factory.int_spinbox(frame, self.var_keyrange_high, 0, 127) spin_bendrange = factory.int_spinbox(frame, self.var_bendrange, 0, 2400) factory.padding_label(frame).grid(row=0) frame_channel.grid(row=1, column=0, rowspan=4, columnspan=2) self.list_channel.pack(side="left", expand=True, fill="both") sb_channel.pack(after=self.list_channel, side="right", expand=True, fill="y") frame_keytab.grid(row=1, column=2, rowspan=4, columnspan=2) self.list_keytab.pack(side="left", expand=True, fill="both") sb_keytab.pack(after=self.list_keytab, side="right", expand=True, fill="y") factory.padding_label(frame).grid(row=6) lab_transpose.grid(row=7, column=0, sticky="w", padx=4, pady=4) spin_transpose.grid(row=7, column=1, padx=4) lab_keyrange.grid(row=8, column=0, sticky="w", padx=4, pady=4) spin_keylow.grid(row=8, column=1, padx=4) spin_keyhigh.grid(row=8, column=2, padx=4) lab_bend.grid(row=9, column=0, sticky="w", padx=4, pady=4) spin_bendrange.grid(row=9, column=1, padx=4) def channel_callback(_): i = self.list_channel.curselection()[0] c = i+1 self.synth.midi_input_channel(c) self.status("MIDI Input Channel = %s" % c) def keytab_callback(_): i = self.list_keytab.curselection()[0] kt = self.list_keytab.get(i) self.synth.keytable(kt) self.status("Using keytable: %s" % kt) def transpose_callback(*_): try: x = int(self.var_transpose.get()) self.synth.transpose(x) self.status("Transpose = %s" % x) except ValueError: self.warning("Invalid transpose") def keyrange_callback(*_): try: a = int(self.var_keyrange_low.get()) b = int(self.var_keyrange_high.get()) a, b = min(a,b), max(a,b) self.synth.key_range((a,b)) self.status("Key range = [%3d, %3d]" % (a, b)) except ValueError: self.warning("Invalid keyrange") def bend_callback(*_): try: b = int(self.var_bendrange.get()) self.synth.bend_range(b) self.status("Bend range = %s" % b) except ValueError: self.warning("Invalid Bendrange") self.list_channel.bind("<<ListboxSelect>>", channel_callback) self.list_keytab.bind("<<ListboxSelect>>", keytab_callback) spin_transpose.config(command=transpose_callback) spin_transpose.bind("<Return>", transpose_callback) spin_keylow.config(command=keyrange_callback) spin_keylow.bind("<Return>", keyrange_callback) spin_keyhigh.config(command=keyrange_callback) spin_keyhigh.bind("<Return>", keyrange_callback) spin_bendrange.config(command=bend_callback) spin_bendrange.bind("<Return>", bend_callback)
def _init_midi_tab(self, master): img = factory.image("resources/Tabs/midi.png") frame = factory.frame(master) master.add(frame, text = "Performance", image=img, compound="top") frame_channel = factory.frame(frame) frame_keytab = factory.frame(frame) lab_transpose = factory.label(frame, "Transpose") lab_keyrange = factory.label(frame, "Key Range") lab_bend = factory.label(frame, "Bend Range") self.list_channel = factory.listbox(frame_channel) sb_channel = factory.scrollbar(frame_channel) sb_channel.config(command=self.list_channel.yview) self.list_channel.config(yscrollcommand=sb_channel.set) self.list_keytab = factory.listbox(frame_keytab) sb_keytab = factory.scrollbar(frame_keytab) sb_keytab.config(command=self.list_keytab.yview) self.list_keytab.config(yscrollcommand=sb_keytab.set) spin_transpose = factory.int_spinbox(frame,self.var_transpose,-36,36) spin_keylow = factory.int_spinbox(frame,self.var_keyrange_low,0,127) spin_keyhigh = factory.int_spinbox(frame,self.var_keyrange_high,0,127) spin_bendrange = factory.int_spinbox(frame,self.var_bendrange, 0, 2400) factory.padding_label(frame).grid(row=0) lab_channel = factory.label(frame,"MIDI Input Channel") lab_channel.grid(row=0,column=0,columnspan=2, pady=8) frame_channel.grid(row=1, column=0, rowspan=4, columnspan=2,padx=8,pady=8) self.list_channel.pack(side="left", expand=True, fill="both") sb_channel.pack(after=self.list_channel, side="right", expand=True, fill="y") lab_ktab = factory.label(frame, "Key Table") lab_ktab.grid(row=0,column=2,columnspan=2,pady=8) frame_keytab.grid(row=1, column=2, rowspan=4, columnspan=2,padx=8,pady=8) self.list_keytab.pack(side="left", expand=True, fill="both") sb_keytab.pack(after=self.list_keytab, side="right", expand=True, fill="y") factory.padding_label(frame).grid(row=6) lab_transpose.grid(row=7, column=0, sticky="w", padx=4, pady=4) lab_keyrange.grid(row=8, column=0, sticky="w", padx=4, pady=4) lab_bend.grid(row=9, column=0, sticky="w", padx=4, pady=4) spin_transpose.grid(row=7, column=1, padx=4) spin_keylow.grid(row=8, column=1, padx=4) spin_keyhigh.grid(row=8, column=2, padx=4) spin_bendrange.grid(row=9, column=1, padx=4) def channel_callback(_): i = self.list_channel.curselection()[0] c = i+1 self.synth.midi_input_channel(c) self.status("MIDI Input Channel = %s" % c) def keytab_callback(_): i = self.list_keytab.curselection()[0] kt = self.list_keytab.get(i) self.synth.keytable(kt) self.status("Using keytable: %s" % kt) def transpose_callback(*_): try: x = int(self.var_transpose.get()) self.synth.transpose(x) self.status("Transpose = %s" % x) except ValueError: self.warning("Invalid transpose") def keyrange_callback(*_): try: a = int(self.var_keyrange_low.get()) b = int(self.var_keyrange_high.get()) a, b = min(a,b), max(a,b) self.synth.key_range((a,b)) self.status("Key range = [%3d, %3d]" % (a, b)) except ValueError: self.warning("Invalid keyrange") def bend_callback(*_): try: b = int(self.var_bendrange.get()) self.synth.bend_range(b) self.status("Bend range = %s" % b) except ValueError: self.warning("Invalid Bendrange") self.list_channel.bind("<<ListboxSelect>>", channel_callback) self.list_keytab.bind("<<ListboxSelect>>", keytab_callback) spin_transpose.config(command=transpose_callback) spin_transpose.bind("<Return>", transpose_callback) spin_keylow.config(command=keyrange_callback) spin_keylow.bind("<Return>", keyrange_callback) spin_keyhigh.config(command=keyrange_callback) spin_keyhigh.bind("<Return>", keyrange_callback) spin_bendrange.config(command=bend_callback) spin_bendrange.bind("<Return>", bend_callback)