def __init__(self, path='', **options): #global sys master = Tix.Tk() Tix.Frame.__init__(self, master) master.title('PyGlossary (Tkinter)') master.resizable(True, False) ######## #icon = Tix.BitmapImage(file='%s%spyglossary.xbm'%(srcDir,os.sep)) #master.wm_iconbitmap(icon) #master.wm_iconbitmap('%s%spyglossary.xbm'%(srcDir,os.sep)) #bit = Tix.PhotoImage(file='%s%spyglossary.gif'%(srcDir,os.sep), format='gif') #lb = Tix.Label(None,image=bit) #lb.grid() #master.iconwindow(icon, 'pyglossary') #master.wm_iconimage(bit) #master.wm_iconname('dot') #help(master.wm_iconbitmap) #for x in dir(master): # if 'wm_' in x: # print x master.wm_iconbitmap('@%s%spyglossary.xbm'%(srcDir,os.sep)) ######## self.pack(fill='x') #master.bind('<Configure>', self.resized) ###################### self.running = False self.glos = Glossary() self.glos.ui = self self.pref = {} self.pref_load() self.pathI = '' self.pathO = '' self.fcd_dir = join(homeDir, 'Desktop') ###################### vpaned = tk.PanedWindow(self, orient=tk.VERTICAL) notebook = Tix.NoteBook(vpaned) notebook.add('tab1', label='Convert', underline=0) notebook.add('tab2', label='Reverse', underline=0) convertFrame = Tix.Frame(notebook.tab1) ###################### frame = Tix.Frame(convertFrame) ## label = Tix.Label(frame, text='Read from format') label.pack(side='left') ## comboVar = tk.StringVar() combo = tk.OptionMenu(frame, comboVar, *Glossary.readDesc) #comboVar.set(Glossary.readDesc[0]) comboVar.set(noneItem) combo.pack(side='left') self.combobox_i = comboVar ## frame.pack(fill='x') ################### frame = Tix.Frame(convertFrame) ## label = Tix.Label(frame, text=' Path:') label.pack(side='left') ## entry = Tix.Entry(frame) entry.pack(side='left', fill='x', expand=True) entry.bind_all('<KeyPress>', self.entry_changed) self.entry_i = entry ## button = Tix.Button(frame, text='Browse', command=self.browse_i, bg='#f0f000', activebackground='#f6f622') button.pack(side='left') ## button = Tix.Button(frame, text='Load', command=self.load, bg='#7777ff', activebackground='#9999ff') button.pack(side='left') ### frame.pack(fill='x') ###################################### self.running = False self.glos = Glossary() self.glos.ui = self self.pref = {} self.pref_load() ###################### frame = Tix.Frame(convertFrame) ## label = Tix.Label(frame, text='Write to format ') label.pack(side='left') ## comboVar = tk.StringVar() combo = tk.OptionMenu(frame, comboVar, *Glossary.writeDesc) #comboVar.set(Glossary.writeDesc[0]) comboVar.set(noneItem) combo.pack(side='left') combo.bind('<Configure>', self.combobox_o_changed) self.combobox_o = comboVar ## frame.pack(fill='x') ################### frame = Tix.Frame(convertFrame) ## label = Tix.Label(frame, text=' Path:') label.pack(side='left') ## entry = Tix.Entry(frame) entry.pack(side='left', fill='x', expand=True) #entry.bind_all('<KeyPress>', self.entry_changed) self.entry_o = entry ## button = Tix.Button(frame, text='Browse', command=self.browse_o, bg='#f0f000', activebackground='#f6f622') button.pack(side='left') ## button = Tix.Button(frame, text='Convert', command=self.convert, bg='#00e000', activebackground='#22f022') button.pack(side='left') ### frame.pack(fill='x') ###### convertFrame.pack(fill='x') vpaned.add(notebook) ###### console = Tix.Text(vpaned, height=15, background='#000000') console.tag_config('stderr', foreground='#ff0000') console.tag_config('stdout', foreground='#00aa00') #self.consoleH = 15 #sbar = Tix.Scrollbar(vpaned, orien=Tix.VERTICAL, command=console.yview) #sbar.grid ( row=0, column=1) #console['yscrollcommand'] = sbar.set #console.grid() console.pack(fill='both', expand=True) self.console = console vpaned.add(console) vpaned.pack(fill='both', expand=True) ###### self.stdout = TkTextFile(console, 'stdout') self.stderr = TkTextFile(console, 'stderr') sys.stdout = self.stdout sys.stderr = self.stderr print('Console:') ############## frame2 = Tix.Frame(self) clearB = Tix.Button(frame2, text='Clear', command=self.console_clear, bg='black', fg='#ffff00', activebackground='#333333', activeforeground='#ffff00') clearB.pack(side='left') #### checkVar = Tix.IntVar() check = Tix.Checkbutton(frame2, variable=checkVar, text='Details') check.pack(side='left') checkVar.set(1) self.checkb_o_det = checkVar ##### pbar = ProgressBar(frame2, width=400) pbar.pack(side='left', fill='x', expand=True) self.pbar = pbar frame2.pack(fill='x') ############# #vpaned.grid() #bottomFrame.grid() #self.grid() ##################### #lbox = Tix.Listbox(convertFrame) #lbox.insert(0, 'aaaaaaaa', 'bbbbbbbbbbbbbbbbbbbb') #lbox.pack(fill='x') ############## frame3 = Tix.Frame(self) aboutB = Tix.Button(frame3, text='About', command=self.about_clicked, bg='#e000e0', activebackground='#f030f0') aboutB.pack(side='right') closeB = Tix.Button(frame3, text='Close', command=self.quit, bg='#ff0000', activebackground='#ff5050') closeB.pack(side='right') applyB = Tix.Button(frame3, text='Apply', command=self.apply_clicked,\ bg='#00e000', activebackground='#22f022') ## 'underline=0' arg in Tix.Button not affect keyboard shortcut????????????? applyB.pack(side='right') frame3.pack(fill='x') ############### Reverse Tab ####################3 revFrame = Tix.Frame(notebook.tab2) revFrame.pack(fill='x') ###################### frame = Tix.Frame(revFrame) ## label = Tix.Label(frame, text='Read from format') label.pack(side='left') ## comboVar = tk.StringVar() combo = tk.OptionMenu(frame, comboVar, *Glossary.readDesc) #comboVar.set(Glossary.readDesc[0]) comboVar.set(noneItem) combo.pack(side='left') self.combobox_r_i = comboVar ## frame.pack(fill='x') ################### frame = Tix.Frame(revFrame) ## label = Tix.Label(frame, text=' Path:') label.pack(side='left') ## entry = Tix.Entry(frame) entry.pack(side='left', fill='x', expand=True) #entry.bind_all('<KeyPress>', self.entry_r_i_changed) self.entry_r_i = entry ## button = Tix.Button(frame, text='Browse', command=self.r_browse_i, bg='#f0f000', activebackground='#f6f622') button.pack(side='left') ## button = Tix.Button(frame, text='Load', command=self.r_load, bg='#7777ff') button.pack(side='left') ### frame.pack(fill='x') ################### frame = Tix.Frame(revFrame) ## label = Tix.Label(frame, text='Output Tabfile') label.pack(side='left') ### entry = Tix.Entry(frame) entry.pack(side='left', fill='x', expand=True) #entry.bind_all('<KeyPress>', self.entry_r_i_changed) self.entry_r_o = entry ## button = Tix.Button(frame, text='Browse', command=self.r_browse_o, bg='#f0f000', activebackground='#f6f622') button.pack(side='left') ## frame.pack(fill='x') ############################## if path!='': self.entry_i.insert(0, path) self.entry_changed() self.load()
def __init__(self, name, default, count, handler, labels=None, longtext=False): self.handler = handler Tix.Toplevel.__init__(self) self.title(name) self.longtext = longtext sw = Tix.ScrolledWindow(self) self.values = sw.window if (labels == None): if (count == 1): label = Tix.Label(self.values, text="Value:") else: label = Tix.Label(self.values, text="Value(s):") pass label.grid(row=0, column=0, sticky="e") self.fields = [] row = 0 for i in range(0, count): if (isbool(default[i])): field = Tix.BooleanVar() field.set(default[i]) w = Tix.Checkbutton(self.values, variable=field) pass elif longtext: field = Tix.Text(self.values) field.insert("1.0", str(default[i])) w = field else: field = Tix.Entry(self.values) field.insert("0", str(default[i])) w = field pass w.grid(row=row, column=1, sticky="ew") row += 1 self.fields.append(field) pass pass else: self.fields = [] row = 0 for i in range(0, count): label = Tix.Label(self.values, text=labels[i]) label.grid(row=row, column=0) if (isbool(default[i])): field = Tix.BooleanVar() field.set(default[i]) w = Tix.Checkbutton(self.values, variable=field) pass elif longtext: field = Tix.Text(self.values) field.insert("1.0", str(default[i])) w = field else: field = Tix.Entry(self.values) field.insert("0", str(default[i])) w = field pass self.fields.append(field) w.grid(row=row, column=1, sticky="ew") row += 1 pass pass sw.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1) self.errstr = gui_errstr.ErrStr(self) self.errstr.pack(side=Tix.TOP, fill=Tix.X, expand=1) bbox = Tix.ButtonBox(self) bbox.add("cancel", text="Cancel", command=lambda w=self: w.cancel()) bbox.add("ok", text="Ok", command=lambda w=self: w.ok()) bbox.pack(side=Tix.BOTTOM, fill=Tix.X, expand=1) self.bind("<Destroy>", self.OnDestroy) return
def __init__(self, name, num_vals, light_list, vals, handler): self.handler = handler self.light_list = light_list Tix.Toplevel.__init__(self) self.title(name) svalues = Tix.ScrolledWindow(self) self.values = svalues.window self.lights = [] row = 0 for i in range(0, num_vals): if (len(vals) <= i): ivals = ("", "black", '0', '1') else: ivals = vals[i] pass label = Tix.Label(self.values, text="Light " + str(i)) label.grid(row=row, column=0, sticky="e") if (light_list[i][0]): lc = Tix.BooleanVar() lcw = Tix.Checkbutton(self.values, text="Local Control", variable=lc) lc.set(ivals[0] == "lc") lcw.grid(row=row, column=1, sticky="ew") row += 1 else: lc = None pass color = EnumHolder() colorw = Tix.Select(self.values, label="Color", allowzero=0, radio=1, command=color.SelectType) for v in light_list[i][1]: colorw.add(v, text=v) pass colorw.configure(value=ivals[1]) colorw.grid(row=row, column=1, sticky="ew") row += 1 ontime = Tix.LabelEntry(self.values, label="On Time") ontime.entry.insert("0", ivals[2]) ontime.grid(row=row, column=1, sticky="ew") row += 1 ontime = ontime.entry offtime = Tix.LabelEntry(self.values, label="Off Time") offtime.entry.insert("0", ivals[3]) offtime.grid(row=row, column=1, sticky="ew") row += 1 offtime = offtime.entry self.lights.append((lc, color, ontime, offtime)) pass svalues.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1) bbox = Tix.ButtonBox(self) bbox.add("cancel", text="Cancel", command=lambda w=self: w.cancel()) bbox.add("ok", text="Ok", command=lambda w=self: w.ok_press()) bbox.pack(side=Tix.BOTTOM, fill=Tix.X, expand=1) self.bind("<Destroy>", self.OnDestroy) return
def __init__(self, parent=None): if __name__ == '__main__': self.myparent = self.myroot = parent self.myparent.rowconfigure(0, weight=1) self.myparent.columnconfigure(0, weight=1) self.outputfr = tk.Frame(self.myparent, width=640, height=480) self.outputfr.rowconfigure(0, weight=1) self.outputfr.rowconfigure(1, weight=0) self.outputfr.columnconfigure(0, weight=1) self.outputfr.grid(row=0, column=0, sticky='nesw') self.nb = tk.NoteBook(self.outputfr, width=640, height=400) self.nb.rowconfigure(0, weight=1) self.nb.columnconfigure(0, weight=1) self.outputbuttons = tk.ButtonBox(self.outputfr, width=640, height=80) self.outputbuttons.add('ok', text='OK', command=self.ok) self.outputbuttons.add('cancel', text='Cancel', command=self.cancel) self.outputbuttons.add('apply', text='Apply', command=self.apply) self.outputbuttons.add('play', text='Play', command=self.audition) self.outputbuttons.add('newinst', text='New Instrument', command=self.newinstrument) self.outputbuttons.grid(row=1, column=0, sticky='') else: self.myparent = parent self.myroot = self.myparent.myparent self.instmaybe = copy.deepcopy(self.myparent.instlist) self.outputfr = tk.Toplevel(self.myroot, width=640, height=480) self.outputfr.bind("<Return>", self.ok) self.outputfr.bind("<Escape>", self.cancel) self.outputfr.title("Output") self.outputfr.rowconfigure(0, weight=1) self.outputfr.rowconfigure(1, weight=0) self.outputfr.columnconfigure(0, weight=1) self.nb = tk.NoteBook(self.outputfr, width=640, height=480) self.nb.rowconfigure(0, weight=1) self.nb.columnconfigure(0, weight=1) self.nb.grid(row=0, column=0, sticky='nesw') self.outputbuttons = tk.ButtonBox(self.outputfr, width=640, height=80) self.outputbuttons.add('ok', text='OK', command=self.ok) self.outputbuttons.add('cancel', text='Cancel', command=self.cancel) self.outputbuttons.add('apply', text='Apply', command=self.apply) self.outputbuttons.add('play', text='Play', command=self.audition) self.outputbuttons.add('newinst', text='New Instrument', command=self.newinstrument) self.outputbuttons.grid(row=1, column=0, sticky='') self.instpagelist = [] self.csdpage = self.nb.add('csd', label='CSD') self.csdpage.rowconfigure(0, weight=1) self.csdpage.rowconfigure(1, weight=0) self.csdpage.columnconfigure(0, weight=1) self.csdpage.columnconfigure(1, weight=1) self.csdtext = tk.Text(self.csdpage) self.csdtext.grid(row=0, column=0, columnspan=2, sticky='nesw') self.csdtext.insert('0.0', self.myparent.csdimported) for i in range(1, len(self.instmaybe)): inst = self.instmaybe[i] newpage = self.addinstpage(inst) for out in inst.outlist: if out.__class__.__name__ == 'csdout': newline = csdline(newpage, out) elif out.__class__.__name__ == 'sf2out': newline = sf2line(newpage, out) self.autoload = tk.BooleanVar() self.autoload.set(self.myparent.outautoload) self.autocheck = tk.Checkbutton(self.csdpage, variable=self.autoload) self.autocheck.grid(row=1, column=0, sticky='e') self.csdloadbutton = tk.Button(self.csdpage, text="Load", command=self.csdload) self.csdloadbutton.grid(row=1, column=1, sticky='w')
def __init__(self, contype, parent): Tix.Frame.__init__(self, parent) self.contype = contype self.fields = [] args = OpenIPMI.alloc_empty_args(str(contype)) self.args = args self.errstr = gui_errstr.ErrStr(self) self.errstr.pack(side=Tix.TOP, fill=Tix.X, expand=1) i = 0 rv = 0 frame = None while (rv == 0): name = [""] vtype = [""] vrange = [""] vhelp = [""] value = [""] rv = args.get_val(i, name, vtype, vhelp, value, vrange) if (rv == 0): if (vhelp[0][0] == '*'): optional = False vhelp[0] = vhelp[0][1:] else: optional = True pass if (vhelp[0][0] == '!'): password = True vhelp[0] = vhelp[0][1:] else: password = False pass if (vtype[0] == "bool"): if (frame == None): didframe = True frame = Tix.Frame(self) frame.pack(side=Tix.TOP) newframe = frame pass else: newframe = None pass fw = Tix.BooleanVar() w = Tix.Checkbutton(frame, text=name[0], variable=fw) w.pack(side=Tix.LEFT, padx=10) if ((value[0] != None) and (value[0] == "true")): fw.set(True) pass pass elif (vtype[0] == "enum"): do_box = False fw = EnumHolder() if (value[0] != None): fw.set(value[0]) pass else: fw.set(vrange[0]) pass w = Tix.Select(self, label=name[0], allowzero=0, radio=1, command=fw.SelectType) for v in vrange: w.add(v, text=v) pass newframe = None w.invoke(fw.get()) w.pack() pass elif (vtype[0] == "str") or (vtype[0] == "int"): if (frame == None): didframe = True frame = Tix.Frame(self) frame.pack(side=Tix.TOP) newframe = frame pass else: newframe = None pass if (value[0] == None): value[0] = "" pass if (password): options = "entry.show '*' entry.width 20" else: options = "entry.width 20" pass w = Tix.LabelEntry(frame, label=name[0], options=options) w.entry.insert(Tix.END, value[0]) w.pack(side=Tix.LEFT, padx=10) fw = w.entry pass else: i += 1 continue frame = newframe self.fields.append((i, name[0], vtype[0], fw)) pass i += 1 pass return
def __init__(self, parent, out): self.page = parent self.out = out self.flag = 's' self.place = self.out.instrument.outlist.index(self.out) self.mute = tk.BooleanVar() self.mute.set(self.out.mute) self.mute.trace("w", self.mutechange) self.solo = tk.BooleanVar() self.solo.set(self.out.solo) self.solo.trace("w", self.solochange) self.sf2file = tk.StringVar() self.sf2file.set(self.out.file) self.sf2file.trace("w", self.filechange) self.bank = tk.IntVar() self.bank.set(self.out.bank) self.bank.trace("w", self.bankchange) self.program = tk.IntVar() self.program.set(self.out.program) self.program.trace("w", self.programchange) self.csdstring = tk.StringVar() self.string = '' self.frame = tk.Frame(self.page.midrow, bd=5, relief="ridge") self.frame.columnconfigure(0, weight=0) self.frame.columnconfigure(1, weight=0) self.frame.columnconfigure(2, weight=0) self.frame.columnconfigure(3, weight=0) self.frame.columnconfigure(4, weight=0) self.frame.columnconfigure(5, weight=0) self.frame.columnconfigure(6, weight=0) self.frame.columnconfigure(7, weight=0) self.frame.columnconfigure(8, weight=0) self.frame.columnconfigure(9, weight=0) self.frame.columnconfigure(10, weight=1) self.field1 = tk.Entry(self.frame, width=2) self.field1.grid(row=0, column=0, sticky='w', pady=10, padx=20) self.field1.insert(0, 's') self.field1.configure(state='disabled') self.mutewidget = tk.Checkbutton(self.frame, height=1, width=1, variable=self.mute, bg='#ffaaaa', selectcolor='#996666', padx=2, pady=0, indicatoron=0, activebackground='#ff8888') self.mutewidget.grid(row=0, column=1, rowspan=1) self.solowidget = tk.Checkbutton(self.frame, height=1, width=1, variable=self.solo, bg='#aaffaa', selectcolor='#669966', padx=2, pady=0, indicatoron=0, activebackground='#88ff88') self.solowidget.grid(row=0, column=2, rowspan=1) self.field2label = tk.Label(self.frame, text="sf2") self.field2label.grid(row=0, column=self.page.sc1, rowspan=1, columnspan=self.page.scs1, sticky='w') self.field2 = tk.ComboBox(self.frame, variable=self.sf2file, editable=0, value="Load") self.field2.entry.configure(width=10) self.field2.grid(row=0, column=self.page.sc2, rowspan=1, columnspan=self.page.scs2, sticky='w', padx=0) self.field2.focus_set() # self.field2.appendhistory("Load") self.field3label = tk.Label(self.frame, text=" bank") self.field3label.grid(row=0, column=self.page.sc3, rowspan=1, columnspan=self.page.scs3, sticky='w') self.field3 = tk.Control(self.frame, min=0, max=128, variable=self.bank) self.field3.grid(row=0, column=self.page.sc4, rowspan=1, columnspan=self.page.scs4, sticky='w') self.field4label = tk.Label(self.frame, text=" prog") self.field4label.grid(row=0, column=self.page.sc5, rowspan=1, columnspan=self.page.scs5, sticky='w') self.field4 = tk.Control(self.frame, min=0, max=128, variable=self.program) self.field4.grid(row=0, column=self.page.sc6, rowspan=1, columnspan=self.page.scs6, sticky='w') self.x = tk.Button(self.frame, text="x", padx=0, pady=0, command=self.remove) self.x.grid(row=0, column=self.page.sc7, sticky='e', padx=40) self.volumewidget = tk.Scale(self.frame, orient="horizontal", width=7, fg='#552288', sliderlength=10, sliderrelief='raised', tickinterval=10, from_=-90, to=10, resolution=.1, variable=self.volume) self.volumewidget.grid(row=1, column=0, columnspan=11, sticky='ew', pady=2) self.page.widget.update_idletasks() bottomy = self.page.midrow.winfo_reqheight() self.page.canvas.coords(self.page.botrowoncanvas, 0, bottomy) self.page.canvas.config(scrollregion=self.page.canvas.bbox("all")) self.page.canvas.yview_moveto(1.0) if self.page.scroll.winfo_ismapped(): # print self.page.scroll.get() pass else: self.page.widget.update_idletasks() # print self.page.scroll.get() if self.page.scroll.get() != (0.0, 1.0): self.page.scroll.grid(row=1, column=1, sticky='ns') self.string = ''
def __init__(self, parent, out): self.page = parent self.out = out self.flag = 'c' # self.place = len(self.page.linelist) self.place = self.out.instrument.outlist.index(self.out) self.mute = tk.BooleanVar() self.mute.set(self.out.mute) self.mute.trace("w", self.mutechange) self.solo = tk.BooleanVar() self.solo.set(self.out.solo) self.solo.trace("w", self.solochange) self.volume = tk.DoubleVar() self.volume.set(self.out.volume) self.volume.trace("w", self.volumechange) self.instnum = tk.StringVar() self.instnum.set(self.out.instnum) self.instnum.trace("w", self.instnumchange) self.csdstring = tk.StringVar() self.csdstring.set(self.out.pfields) self.csdstring.trace("w", self.csdstringchange) self.frame = tk.Frame(self.page.midrow, bd=5, relief="ridge") self.frame.grid(row=self.place, column=0, columnspan=2, sticky='ew') self.frame.columnconfigure(0, weight=0) self.frame.columnconfigure(1, weight=0) self.frame.columnconfigure(2, weight=0) self.frame.columnconfigure(3, weight=0) self.frame.columnconfigure(4, weight=0) self.frame.columnconfigure(5, weight=0) self.frame.columnconfigure(6, weight=0) self.frame.columnconfigure(7, weight=0) self.frame.columnconfigure(8, weight=1) self.field1 = tk.Entry(self.frame, width=2) self.field1.grid(row=0, column=0, sticky='w', pady=10, padx=20) self.field1.insert(0, 'c') self.field1.configure(state='disabled') self.mutewidget = tk.Checkbutton(self.frame, height=1, width=1, variable=self.mute, bg='#ffaaaa', selectcolor='#996666', padx=2, pady=0, indicatoron=0, activebackground='#ff8888') self.mutewidget.grid(row=0, column=1, rowspan=1) self.solowidget = tk.Checkbutton(self.frame, height=1, width=1, variable=self.solo, bg='#aaffaa', selectcolor='#669966', padx=2, pady=0, indicatoron=0, activebackground='#88ff88') self.solowidget.grid(row=0, column=2, rowspan=1) self.field2label = tk.Label(self.frame, text="inst") self.field2label.grid(row=0, column=self.page.cc1, rowspan=1, columnspan=self.page.ccs1, sticky='w') self.field2 = tk.Entry(self.frame, width=8, textvariable=self.instnum) self.field2.grid(row=0, column=self.page.cc2, rowspan=1, columnspan=self.page.ccs2, sticky='w') self.field2.focus_set() self.field2.select_range(0, "end") self.field2.bind("<FocusOut>", self.stringupdate) self.field3label = tk.Label(self.frame, text=" time dur ") self.field3label.grid(row=0, column=self.page.cc3, rowspan=1, columnspan=self.page.ccs3) self.field3 = tk.Entry(self.frame, width=30, textvariable=self.csdstring) self.field3.grid(row=0, column=self.page.cc4, rowspan=1, columnspan=self.page.ccs4, sticky='w') self.field3.bind("<FocusOut>", self.stringupdate) self.x = tk.Button(self.frame, text="x", padx=0, pady=0, command=self.remove) self.x.grid(row=0, column=self.page.cc5, sticky='e', padx=40) self.volumewidget = tk.Scale(self.frame, orient="horizontal", width=7, fg='#552288', sliderlength=10, sliderrelief='raised', tickinterval=10, from_=-90, to=10, resolution=.1, variable=self.volume) self.volumewidget.set(self.out.volume) self.volumewidget.grid(row=1, column=0, columnspan=11, sticky='ew', pady=2) self.page.widget.update_idletasks() bottomy = self.page.midrow.winfo_reqheight() self.page.canvas.coords(self.page.botrowoncanvas, 0, bottomy) self.page.canvas.config(scrollregion=self.page.canvas.bbox("all")) self.page.canvas.yview_moveto(1.0) if self.page.scroll.winfo_ismapped(): # print self.page.scroll.get() pass else: self.page.widget.update_idletasks() # print self.page.scroll.get() if self.page.scroll.get() != (0.0, 1.0): self.page.scroll.grid(row=1, column=1, sticky='ns')
def __init__(self, parent, inst): self.myparent = parent self.myinst = inst number = self.myinst.number self.linelist = [] self.mute = tk.BooleanVar() self.mute.set(self.myinst.mute) self.mute.trace("w", self.mutechange) self.solo = tk.BooleanVar() self.solo.set(self.myinst.solo) self.solo.trace("w", self.solochange) self.widget = self.myparent.nb.add('inst%.4d' % number, label='i%d' % number, raisecmd=lambda arg1=0.0: self.canvas.yview_moveto(arg1)) self.widget.rowconfigure(0, weight=0) self.widget.rowconfigure(1, weight=1) # self.widget.rowconfigure(2, weight=1) # self.widget.rowconfigure(3, weight=1) self.widget.columnconfigure(0, weight=1) # self.widget.columnconfigure(1, weight=1) self.toprow = tk.Frame(self.widget) self.toprow.grid(row=0, column=0, sticky='we') self.toprow.columnconfigure(0, weight=0) self.toprow.columnconfigure(1, weight=0) self.toprow.columnconfigure(2, weight=0) self.toprow.columnconfigure(3, weight=1) self.canvas = tk.Canvas(self.widget) self.canvas.grid(row=1, column=0, sticky='nesw') self.canvas.rowconfigure(2, weight=1) self.canvas.columnconfigure(0, weight=1) self.midrow = tk.Frame(self.canvas) # self.midrow.grid(row=0, column=0, sticky='we') self.midrowoncanvas = self.canvas.create_window(0, 0, window=self.midrow, anchor="nw") self.midrow.columnconfigure(0, weight=0) self.midrow.columnconfigure(1, weight=1) self.botrow = tk.Frame(self.canvas, bd=5, relief="ridge") # self.botrow.grid(row=1, column=0, sticky='we') self.botrow.columnconfigure(0, weight=0) self.botrow.columnconfigure(1, weight=1) # self.scroll = tk.Scrollbar(self.widget, orient='vertical', takefocus=0, troughcolor="#ccaaaa", activebackground="#cc7777", bg="#cc8f8f") self.scroll = tk.Scrollbar(self.widget, orient='vertical', takefocus=0) self.canvas.config(yscrollcommand=self.scroll.set) self.canvas.config(scrollregion=self.canvas.bbox("all")) self.scroll.config(command=self.canvas.yview) self.myparent.outputfr.bind("<Button-4>", lambda event, arg1="scroll", arg2=-1, arg3="units": self.canvas.yview(arg1, arg2, arg3), "+") self.myparent.outputfr.bind("<Button-5>", lambda event, arg1="scroll", arg2=1, arg3="units": self.canvas.yview(arg1, arg2, arg3), "+") # self.scroll.grid(row=1, column=1, sticky='ns') # SF2 LINE GRID COLUMNS self.sc1 = 3 self.scs1 = 1 self.sc2 = 4 self.scs2 = 1 self.sc3 = 5 self.scs3 = 1 self.sc4 = 6 self.scs4 = 1 self.sc5 = 7 self.scs5 = 1 self.sc6 = 8 self.scs6 = 1 self.sc7 = 9 self.scs7 = 1 # CSOUND LINE GRID COLUMNS self.cc1 = 3 self.ccs1 = 1 self.cc2 = 4 self.ccs2 = 1 self.cc3 = 5 self.ccs3 = 1 self.cc4 = 6 self.ccs4 = 1 self.cc5 = 7 self.ccs5 = 1 self.color = tk.StringVar() self.color.set(self.myinst.color) self.color.trace("w", self.colorchange) self.colorwidget = tk.Frame(self.toprow, width=40, height=40, bg=self.color.get()) self.colorwidget.grid(row=0, column=0, padx=10) self.colorwidget.bind("<Button-1>", self.colorchoose) self.mutewidget = tk.Checkbutton(self.toprow, bg='#ffaaaa', text='M', variable=self.mute, indicatoron=1, activebackground='#ffaaaa', selectcolor='#ff0000', width=1, height=1, bd=2, highlightthickness=0) self.mutewidget.grid(row=0, column=1, padx=4) self.solowidget = tk.Checkbutton(self.toprow, bg='#00aa00', text='S', variable=self.solo, indicatoron=1, activebackground='#00aa00', selectcolor='#00ff00', width=1, height=1, bd=2, highlightthickness=0) self.solowidget.grid(row=0, column=2) self.blank = tk.Entry(self.botrow, width=2) self.blank.grid(row=0, column=0, pady=10, padx=20, sticky='w') self.blank.bind("<Tab>", self.outputselect) self.widget.update_idletasks() bottomy = self.midrow.winfo_reqheight() # print bottomy self.botrowoncanvas = self.canvas.create_window(0, bottomy, window=self.botrow, anchor="nw")
def WhiteListWindowEdit(project_name, rule_name, variable): typeVar = Tix.StringVar() WhiteListWindow = Tix.Toplevel() WhiteListWindow.title("Edit White Cue List") WhiteListWindow.geometry('{}x{}'.format(550, 550)) itemsFrame = Tix.Frame(WhiteListWindow) itemsFrame.pack(side=Tix.LEFT) choiseFrame = Tix.Frame(WhiteListWindow, width=130) choiseFrame.pack(side=Tix.RIGHT) wl_where_to_look = Tix.Label(choiseFrame, text="Where to look in whitelist?").grid( row=2, column=0, sticky='w') wl_look_head = Tix.IntVar() wl_HeaderCB = Tix.Checkbutton(choiseFrame, text="Header", variable=wl_look_head).grid(row=3, column=0, sticky='w') wl_look_stub = Tix.IntVar() wl_StubCB = Tix.Checkbutton(choiseFrame, text="Stub", variable=wl_look_stub).grid(row=4, column=0, sticky='w') wl_look_super = Tix.IntVar() wl_SuperRowCB = Tix.Checkbutton(choiseFrame, text="Super-row", variable=wl_look_super).grid(row=5, column=0, sticky='w') wl_look_data = Tix.IntVar() wl_DataCB = Tix.Checkbutton(choiseFrame, text="Data", variable=wl_look_data).grid(row=6, column=0, sticky='w') bl_where_to_look = Tix.Label(choiseFrame, text="Where to look in blacklist?").grid( row=7, column=0, sticky='w') bl_look_head = Tix.IntVar() bl_HeaderCB = Tix.Checkbutton(choiseFrame, text="Header", variable=bl_look_head).grid(row=8, column=0, sticky='w') bl_look_stub = Tix.IntVar() bl_StubCB = Tix.Checkbutton(choiseFrame, text="Stub", variable=bl_look_stub).grid(row=9, column=0, sticky='w') bl_look_super = Tix.IntVar() bl_SuperRowCB = Tix.Checkbutton(choiseFrame, text="Super-row", variable=bl_look_super).grid(row=10, column=0, sticky='w') bl_look_data = Tix.IntVar() bl_DataCB = Tix.Checkbutton(choiseFrame, text="Data", variable=bl_look_data).grid(row=11, column=0, sticky='w') #look_all = Tix.IntVar() #EverywhereCB = Tix.Checkbutton(choiseFrame,text="Everywhere",variable=look_all).grid(row=7,column=0,sticky='w') namerule_label2 = Tix.Label( itemsFrame, text= "To look for annotations ids (such as CUI from UMLS)\nwrite [annID]: (eg. '[annID]:C1696465'). To look\nfor annotation types (such as Semantic Type\nin UMLS) write [annType]: in front of cue (e.g.\n'[annType]:Biomedical or Dental Materia' or\n'[annType]:(bodm)'). To write just lexical cue,\njust write word, without prefixes, or [word]:\n(e.g. 'age' or '[word]:age')", justify=Tix.LEFT).grid(row=0, sticky='w') namerule_label = Tix.Label( itemsFrame, text="List of terms in whitelsit").grid(row=1, sticky='w') WhiteListText = Tix.Text(itemsFrame, height=10, width=50) WhiteListText.grid(row=2, sticky='w') whitelist = FileManipulationHelper.loadWhiteList(project_name, rule_name, variable) namerule_label2 = Tix.Label( itemsFrame, text="List of terms in blacklsit").grid(row=3, sticky='w') BlackListText = Tix.Text(itemsFrame, height=10, width=50) BlackListText.grid(row=4, sticky='w') blacklist = FileManipulationHelper.loadBlackList(project_name, rule_name, variable) i = 1 afterWordList = False for w in whitelist: w = w.replace('\n', '') splitted = w.split(':') #if splitted[0]=='Type': # if splitted[1]=='WhiteList': # typeVar.set(type[0]) # else: # typeVar.set(type[1]) if splitted[0] == 'Header': wl_look_head.set(int(splitted[1])) if splitted[0] == 'Stub': wl_look_stub.set(int(splitted[1])) if splitted[0] == 'Super-row': wl_look_super.set(int(splitted[1])) if splitted[0] == 'Data': wl_look_data.set(int(splitted[1])) #if splitted[0]=='All': # look_all.set(int(splitted[1])) if w == "WordList:": afterWordList = True continue if afterWordList == True: WhiteListText.insert(str(i) + '.0', w + '\n') i = i + 1 afterWordList = False for w in blacklist: w = w.replace('\n', '') splitted = w.split(':') #if splitted[0]=='Type': # if splitted[1]=='WhiteList': # typeVar.set(type[0]) # else: # typeVar.set(type[1]) if splitted[0] == 'Header': bl_look_head.set(int(splitted[1])) if splitted[0] == 'Stub': bl_look_stub.set(int(splitted[1])) if splitted[0] == 'Super-row': bl_look_super.set(int(splitted[1])) if splitted[0] == 'Data': bl_look_data.set(int(splitted[1])) #if splitted[0]=='All': # look_all.set(int(splitted[1])) if w == "WordList:": afterWordList = True continue if afterWordList == True: BlackListText.insert(str(i) + '.0', w + '\n') i = i + 1 ClsVar = Tix.StringVar() ClsVar.set(variable) saveButton = Tix.Button( itemsFrame, text="Save", fg="black", command=lambda: SaveWhiteListEdit( WhiteListText.get("1.0", Tix.END), BlackListText.get( "1.0", Tix.END), typeVar, wl_look_head, wl_look_stub, wl_look_super, wl_look_data, bl_look_head, bl_look_stub, bl_look_super, bl_look_data, WhiteListWindow, project_name, rule_name, ClsVar)).grid(row=12, column=0, sticky='w')
def WhiteListWindow(project_name, rule_name, vClsIn): WhiteListWindow = Tix.Toplevel() WhiteListWindow.title("Edit Cue List") WhiteListWindow.geometry('{}x{}'.format(550, 550)) itemsFrame = Tix.Frame(WhiteListWindow) itemsFrame.pack(side=Tix.LEFT) choiseFrame = Tix.Frame(WhiteListWindow, width=130) choiseFrame.pack(side=Tix.RIGHT) #type = ['WhiteList','BlackList'] typeVar = Tix.StringVar() #typeVar.set(type[0]) #TypeLabel = Label(choiseFrame,text="ListType").grid(row=0,column=0,sticky='w') #drop = OptionMenu(choiseFrame,typeVar,*type) #drop.grid(row=1,column=0,sticky='w') where_to_look = Tix.Label(choiseFrame, text="Where to look for white list cues?").grid( row=2, column=0, sticky='w') wl_look_head = Tix.IntVar() WLHeaderCB = Tix.Checkbutton(choiseFrame, text="Header", variable=wl_look_head).grid(row=3, column=0, sticky='w') wl_look_stub = Tix.IntVar() WLStubCB = Tix.Checkbutton(choiseFrame, text="Stub", variable=wl_look_stub).grid(row=4, column=0, sticky='w') wl_look_super = Tix.IntVar() WLSuperRowCB = Tix.Checkbutton(choiseFrame, text="Super-row", variable=wl_look_super).grid(row=5, column=0, sticky='w') wl_look_data = Tix.IntVar() WLDataCB = Tix.Checkbutton(choiseFrame, text="Data", variable=wl_look_data).grid(row=6, column=0, sticky='w') where_to_look2 = Tix.Label(choiseFrame, text="Where to look for black list cues?").grid( row=7, column=0, sticky='w') bl_look_head = Tix.IntVar() BLHeaderCB = Tix.Checkbutton(choiseFrame, text="Header", variable=bl_look_head).grid(row=8, column=0, sticky='w') bl_look_stub = Tix.IntVar() BLStubCB = Tix.Checkbutton(choiseFrame, text="Stub", variable=bl_look_stub).grid(row=9, column=0, sticky='w') bl_look_super = Tix.IntVar() BLSuperRowCB = Tix.Checkbutton(choiseFrame, text="Super-row", variable=bl_look_super).grid(row=10, column=0, sticky='w') bl_look_data = Tix.IntVar() BLDataCB = Tix.Checkbutton(choiseFrame, text="Data", variable=bl_look_data).grid(row=11, column=0, sticky='w') namerule_label2 = Tix.Label( itemsFrame, text= "To look for annotations ids (such as CUI from UMLS)\nwrite [annID]: (eg. '[annID]:C1696465'). To look\nfor annotation types (such as Semantic Type\nin UMLS) write [annType]: in front of cue (e.g.\n'[annType]:Biomedical or Dental Materia' or\n'[annType]:(bodm)'). To write just lexical cue,\njust write word, without prefixes, or [word]:\n(e.g. 'age' or '[word]:age')", justify=Tix.LEFT).grid(row=0, sticky='w') namerule_label = Tix.Label( itemsFrame, text="List of terms in whitelist").grid(row=1, sticky='w') whitelist = Tix.Text(itemsFrame, height=5, width=50) whitelist.grid(row=2, sticky='w') namerule_label2 = Tix.Label( itemsFrame, text="List of terms in blacklist").grid(row=3, sticky='w') blacklist = Tix.Text(itemsFrame, height=5, width=50) blacklist.grid(row=4, sticky='w') saveButton = Tix.Button( itemsFrame, text="Save", fg="black", command=lambda: SaveWhiteList( whitelist.get("1.0", Tix.END), blacklist.get("1.0", Tix.END), typeVar, wl_look_head, wl_look_stub, wl_look_super, wl_look_data, bl_look_head, bl_look_stub, bl_look_super, bl_look_data, WhiteListWindow, project_name, rule_name, vClsIn)).grid(row=5, sticky='w')
def SemanticListWindow(project_name, rule_name, vClsIn): # WhiteListWindow = Tix.Toplevel() WhiteListWindow.title("Edit Cue List") WhiteListWindow.geometry('{}x{}'.format(550, 400)) itemsFrame = Tix.Frame(WhiteListWindow) itemsFrame.pack(side=Tix.LEFT) choiseFrame = Tix.Frame(WhiteListWindow, width=130) choiseFrame.pack(side=Tix.RIGHT) #type = ['WhiteList','BlackList'] typeVar = Tix.StringVar() #typeVar.set(type[0]) #TypeLabel = Label(choiseFrame,text="ListType").grid(row=0,column=0,sticky='w') #drop = OptionMenu(choiseFrame,typeVar,*type) #drop.grid(row=1,column=0,sticky='w') where_to_look = Tix.Label( choiseFrame, text="Where to look for white list variables?").grid(row=2, column=0, sticky='w') wl_look_head = Tix.IntVar() WLHeaderCB = Tix.Checkbutton(choiseFrame, text="Header", variable=wl_look_head).grid(row=3, column=0, sticky='w') wl_look_stub = Tix.IntVar() WLStubCB = Tix.Checkbutton(choiseFrame, text="Stub", variable=wl_look_stub).grid(row=4, column=0, sticky='w') wl_look_super = Tix.IntVar() WLSuperRowCB = Tix.Checkbutton(choiseFrame, text="Super-row", variable=wl_look_super).grid(row=5, column=0, sticky='w') wl_look_data = Tix.IntVar() WLDataCB = Tix.Checkbutton(choiseFrame, text="Data", variable=wl_look_data).grid(row=6, column=0, sticky='w') where_to_look2 = Tix.Label( choiseFrame, text="Where to look for black list variables?").grid(row=7, column=0, sticky='w') bl_look_head = Tix.IntVar() BLHeaderCB = Tix.Checkbutton(choiseFrame, text="Header", variable=bl_look_head).grid(row=8, column=0, sticky='w') bl_look_stub = Tix.IntVar() BLStubCB = Tix.Checkbutton(choiseFrame, text="Stub", variable=bl_look_stub).grid(row=9, column=0, sticky='w') bl_look_super = Tix.IntVar() BLSuperRowCB = Tix.Checkbutton(choiseFrame, text="Super-row", variable=bl_look_super).grid(row=10, column=0, sticky='w') bl_look_data = Tix.IntVar() BLDataCB = Tix.Checkbutton(choiseFrame, text="Data", variable=bl_look_data).grid(row=11, column=0, sticky='w') namerule_label = Tix.Label( itemsFrame, text="List of terms in whitelsit").grid(row=0, sticky='w') whitelist = Tix.CheckList(itemsFrame, width=350) whitelist.grid(row=1, sticky='w') createSemanticWhiteList(whitelist) whitelist.autosetmode() namerule_label2 = Tix.Label( itemsFrame, text="List of terms in blacklist").grid(row=2, sticky='w') blacklist = Tix.Text(itemsFrame, height=5, width=50) blacklist.grid(row=3, sticky='w') saveButton = Tix.Button( itemsFrame, text="Save", fg="black", command=lambda: SaveWhiteListSemantic( whitelist, blacklist.get("1.0", Tix.END), typeVar, wl_look_head, wl_look_stub, wl_look_super, wl_look_data, bl_look_head, bl_look_stub, bl_look_super, bl_look_data, WhiteListWindow, project_name, rule_name, vClsIn)).grid(row=4, sticky='w') pass
def SemanticListWindowEdit(project_name, rule_name, variable_name): # WhiteListWindow = Tix.Toplevel() WhiteListWindow.title("Edit Cue List") WhiteListWindow.geometry('{}x{}'.format(550, 400)) itemsFrame = Tix.Frame(WhiteListWindow) itemsFrame.pack(side=Tix.LEFT) choiseFrame = Tix.Frame(WhiteListWindow, width=130) choiseFrame.pack(side=Tix.RIGHT) #type = ['WhiteList','BlackList'] typeVar = Tix.StringVar() #typeVar.set(type[0]) #TypeLabel = Label(choiseFrame,text="ListType").grid(row=0,column=0,sticky='w') #drop = OptionMenu(choiseFrame,typeVar,*type) #drop.grid(row=1,column=0,sticky='w') where_to_look = Tix.Label( choiseFrame, text="Where to look for white list variables?").grid(row=2, column=0, sticky='w') wl_look_head = Tix.IntVar() WLHeaderCB = Tix.Checkbutton(choiseFrame, text="Header", variable=wl_look_head).grid(row=3, column=0, sticky='w') wl_look_stub = Tix.IntVar() WLStubCB = Tix.Checkbutton(choiseFrame, text="Stub", variable=wl_look_stub).grid(row=4, column=0, sticky='w') wl_look_super = Tix.IntVar() WLSuperRowCB = Tix.Checkbutton(choiseFrame, text="Super-row", variable=wl_look_super).grid(row=5, column=0, sticky='w') wl_look_data = Tix.IntVar() WLDataCB = Tix.Checkbutton(choiseFrame, text="Data", variable=wl_look_data).grid(row=6, column=0, sticky='w') where_to_look2 = Tix.Label( choiseFrame, text="Where to look for black list variables?").grid(row=7, column=0, sticky='w') bl_look_head = Tix.IntVar() BLHeaderCB = Tix.Checkbutton(choiseFrame, text="Header", variable=bl_look_head).grid(row=8, column=0, sticky='w') bl_look_stub = Tix.IntVar() BLStubCB = Tix.Checkbutton(choiseFrame, text="Stub", variable=bl_look_stub).grid(row=9, column=0, sticky='w') bl_look_super = Tix.IntVar() BLSuperRowCB = Tix.Checkbutton(choiseFrame, text="Super-row", variable=bl_look_super).grid(row=10, column=0, sticky='w') bl_look_data = Tix.IntVar() BLDataCB = Tix.Checkbutton(choiseFrame, text="Data", variable=bl_look_data).grid(row=11, column=0, sticky='w') namerule_label = Tix.Label( itemsFrame, text="List of terms in whitelsit").grid(row=0, sticky='w') whitelist = Tix.CheckList(itemsFrame, width=350) whitelist.grid(row=1, sticky='w') createSemanticWhiteList(whitelist) whitelist.autosetmode() namerule_label2 = Tix.Label( itemsFrame, text="List of terms in blacklist").grid(row=2, sticky='w') blacklist = Tix.Text(itemsFrame, height=5, width=50) blacklist.grid(row=3, sticky='w') whitelist_list = FileManipulationHelper.loadWhiteList( project_name, rule_name, variable_name) blacklist_list = FileManipulationHelper.loadBlackList( project_name, rule_name, variable_name) i = 1 afterWordList = False for w in whitelist_list: w = w.replace('\n', '') splitted = w.split(':') #if splitted[0]=='Type': # if splitted[1]=='WhiteList': # typeVar.set(type[0]) # else: # typeVar.set(type[1]) if splitted[0] == 'Header': wl_look_head.set(int(splitted[1])) if splitted[0] == 'Stub': wl_look_stub.set(int(splitted[1])) if splitted[0] == 'Super-row': wl_look_super.set(int(splitted[1])) if splitted[0] == 'Data': wl_look_data.set(int(splitted[1])) #if splitted[0]=='All': # look_all.set(int(splitted[1])) if w == "SemanticTypes:": afterWordList = True continue if afterWordList == True: cur = 0 for item in semanticTypes: if (w == item.split('.')[-1]): whitelist.setstatus(item, "on") cur = cur + 1 i = i + 1 afterWordList = False for w in blacklist_list: w = w.replace('\n', '') splitted = w.split(':') #if splitted[0]=='Type': # if splitted[1]=='WhiteList': # typeVar.set(type[0]) # else: # typeVar.set(type[1]) if splitted[0] == 'Header': bl_look_head.set(int(splitted[1])) if splitted[0] == 'Stub': bl_look_stub.set(int(splitted[1])) if splitted[0] == 'Super-row': bl_look_super.set(int(splitted[1])) if splitted[0] == 'Data': bl_look_data.set(int(splitted[1])) #if splitted[0]=='All': # look_all.set(int(splitted[1])) if w == "WordList:": afterWordList = True continue if afterWordList == True: blacklist.insert(str(i) + '.0', w + '\n') i = i + 1 saveButton = Tix.Button( itemsFrame, text="Save", fg="black", command=lambda: SaveWhiteListSemanticEdit( whitelist, blacklist.get("1.0", Tix.END), typeVar, wl_look_head, wl_look_stub, wl_look_super, wl_look_data, bl_look_head, bl_look_stub, bl_look_super, bl_look_data, WhiteListWindow, project_name, rule_name)).grid(row=4, sticky='w') pass