def body(self, parent): import notebook notebook = notebook.notebook(parent, side=TOP) for group in self.opts: tab = Frame(notebook()) for optnumber, option in enumerate(group): optf = Frame(tab) label = Label(optf, text=getPrettyName(option)) label.pack(fill=Y, side=LEFT) if option.type in ( 'String', 'Integer', 'Password' ): if option.type == 'Password': edit = Entry(optf, show='*') else: edit = Entry(optf) val = option.getValue() if val and val is not NoDefaultOption: edit.insert(0,str(val)) edit.pack(fill=BOTH, side=RIGHT) get = edit.get edit = ( optf, label, edit ) elif option.type == 'Choice': rbf = Frame(optf) buttons = [] name = option.name val = option.value self.choiceoptions[name] = val for c in [x.value for x in option]: if c == val: E = 1 else: E = 0 b = Radiobutton(rbf, text=c, indicatoron=1, variable=self.choiceoptions[name], value=c, command=lambda o=self.choiceoptions, n=name, c=c: o.__setitem__(n,c) ) if E: b.select() else: b.deselect() b.pack(side=LEFT) buttons.append(b) rbf.pack(side=RIGHT, fill=BOTH) get = lambda opt=name: self.choiceoptions[opt] edit = ( rbf, buttons ) elif option.optionType == 'Boolean': name = option.name val = option.value self.booloptions[name] = val b = Checkbutton(optf, variable=self.booloptions[name], command=lambda o=self.booloptions, n=name: o.__setitem__(n, not o[n]) ) b.pack(side=RIGHT, fill=BOTH) edit = b get = lambda opt=name: self.booloptions[opt] else: raise ValueError, "unknown option type %s"%(option.optionType) optf.pack(fill=X, side=TOP, ipady=4) if edit is not None: self.options[option.name] = ( option.type, get, edit ) notebook.add_screen(tab, group.name) return notebook()
def __init__(self, *args, **kwargs): tk.Tk.__init__(self, *args, **kwargs) self.variables ={} self.subvariables={} n=notebook(tk.Tk(), LEFT) for label in sorted(data.keys()): self.variables[label] = tk.IntVar() f=Frame(n()) n.add_screen(f, label) for sublabel in sorted(data[label][data[label].keys()[0]].keys()): self.subvariables[sublabel]=tk.IntVar() cb = tk.Checkbutton(self, text=sublabel, onvalue=data[label][data[label].keys()[0]][sublabel], offvalue=0, variable=self.subvariables[sublabel]) cb.pack(side="top", fill="x")
def initUI(self): self.parent.title( "Uhura V0.2: An English -> RMPL/PDDL Translator by Peng Yu and Jonathan Trevino" ) self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) w = 940 h = 1000 sw = self.parent.winfo_screenwidth() sh = self.parent.winfo_screenheight() x = (sw - w) / 2 y = (sh - h) / 2 self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y)) #TranslatorFrame = Frame(self,width=980, height=880,borderwidth=1, background="azure2") Tabs = notebook(self, TOP) TranslatorFrame = Frame(Tabs(), width=930, height=980, borderwidth=1, background="azure2") self.buildTranslatorFrame(TranslatorFrame) RMPLTestFrame = Frame(Tabs(), width=930, height=980, borderwidth=1, background="azure2") self.buildRMPLFrame(RMPLTestFrame) PDDLTestFrame = Frame(Tabs(), width=930, height=980, borderwidth=1, background="azure2") self.buildPDDLFrame(PDDLTestFrame) Tabs.add_screen(TranslatorFrame, " Translator ") Tabs.add_screen(RMPLTestFrame, " RMPL Test ") Tabs.add_screen(PDDLTestFrame, " PDDL Test ") print 'Done making GUI'
def initUI(self): self.parent.title("Uhura V0.2: An English -> RMPL/PDDL Translator by Peng Yu and Jonathan Trevino") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) w = 940 h = 1000 sw = self.parent.winfo_screenwidth() sh = self.parent.winfo_screenheight() x = (sw - w)/2 y = (sh - h)/2 self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y)) #TranslatorFrame = Frame(self,width=980, height=880,borderwidth=1, background="azure2") Tabs = notebook(self, TOP) TranslatorFrame = Frame(Tabs(),width=930, height=980,borderwidth=1, background="azure2") self.buildTranslatorFrame(TranslatorFrame) RMPLTestFrame = Frame(Tabs(),width=930, height=980,borderwidth=1, background="azure2") self.buildRMPLFrame(RMPLTestFrame) PDDLTestFrame = Frame(Tabs(),width=930, height=980,borderwidth=1, background="azure2") self.buildPDDLFrame(PDDLTestFrame) Tabs.add_screen(TranslatorFrame, " Translator ") Tabs.add_screen(RMPLTestFrame, " RMPL Test ") Tabs.add_screen(PDDLTestFrame, " PDDL Test ") print 'Done making GUI'
except ImportError: # for Python3 from tkinter import * ## notice lowercase 't' in tkinter here from notebook import * # window with tabs from stftMorph_GUI_frame import * from sineTransformations_GUI_frame import * from harmonicTransformations_GUI_frame import * from stochasticTransformations_GUI_frame import * from hpsTransformations_GUI_frame import * from hpsMorph_GUI_frame import * root = Tk() root.title('sms-tools transformations GUI') nb = notebook( root, TOP) # make a few diverse frames (panels), each using the NB as 'master': # uses the notebook's frame f1 = Frame(nb()) stft = StftMorph_frame(f1) f2 = Frame(nb()) sine = SineTransformations_frame(f2) f3 = Frame(nb()) harmonic = HarmonicTransformations_frame(f3) f4 = Frame(nb()) stochastic = StochasticTransformations_frame(f4)
from Tkinter import * from notebook import * # window with tabs from dftModel_GUI_frame import * from stft_GUI_frame import * from sineModel_GUI_frame import * from harmonicModel_GUI_frame import * from stochasticModel_GUI_frame import * from sprModel_GUI_frame import * from spsModel_GUI_frame import * from hprModel_GUI_frame import * from hpsModel_GUI_frame import * root = Tk( ) root.title('sms-tools GUI') nb = notebook(root, TOP) # make a few diverse frames (panels), each using the NB as 'master': # uses the notebook's frame f1 = Frame(nb( )) dft = DftModel_frame(f1) f2 = Frame(nb( )) stft = Stft_frame(f2) f3 = Frame(nb( )) sine = SineModel_frame(f3) f4 = Frame(nb( )) harmonic = HarmonicModel_frame(f4) f5 = Frame(nb( ))
def __init__(self, master): self.m_renderWin = None self.m_master = master self.m_robotDriveProgress = 0 self.m_paused = False # choose file button controlBtnsFrame = Frame(master) controlBtnsFrame.pack(side=TOP) self.fileLabelVar = StringVar() self.fileLabelVar.set("No file") self.fileLabel = Label(controlBtnsFrame, textvariable=self.fileLabelVar, justify=LEFT) self.fileLabel.pack(side=BOTTOM, fill=BOTH, anchor=SW) self.chooseFileBtn = Button(controlBtnsFrame, text="Choose Image File", command=self.chooseFile) self.chooseFileBtn.pack(side=LEFT) self.processImageBtn = Button(controlBtnsFrame, text="Process", justify=LEFT, relief=RAISED, command=self.processFile) self.processImageBtn.pack(side=LEFT, fill=BOTH) self.renderImageBtn = Button(controlBtnsFrame, text="Render", justify=LEFT, relief=RAISED, command=self.renderFile) self.renderImageBtn.pack(side=LEFT, fill=BOTH) self.robotDrawBtn = Button(controlBtnsFrame, text="Send to Robot", justify=LEFT, relief=RAISED, command=self.sendToRobot) self.robotDrawBtn.pack(side=LEFT, fill=BOTH) self.robotPauseBtn = Button(controlBtnsFrame, text="Pause", justify=LEFT, relief=RAISED, command=self.pauseDrawing) self.robotPauseBtn.pack(side=LEFT, fill=BOTH) self.robotResumeBtn = Button(controlBtnsFrame, text="Resume", justify=LEFT, relief=RAISED, command=self.resumeDrawing) self.robotResumeBtn.pack(side=LEFT, fill=BOTH) self.setButtonsOff() self.progFrame = Frame(master) self.progBar = ttk.Progressbar(self.progFrame, maximum=100.1) self.timeLabelVar = StringVar() self.timeLabelVar.set("00:00:00 / 00:00:00") self.timeLabel = Label(self.progFrame, textvariable=self.timeLabelVar, justify=LEFT) self.progFrame.pack(side=BOTTOM, fill=BOTH, anchor=SW) self.progBar.pack(side=LEFT, fill=BOTH, expand=True, anchor=SW) self.timeLabel.pack(side=BOTTOM, anchor=E) nbFrame = Frame(master) nbFrame.pack(side=TOP, fill=BOTH, expand=1) self.nb = notebook(nbFrame, TOP) # mkbitmap options self.mbOptsGroup = LabelFrame(self.nb, text="mkbitmap options", padx=5, pady=5) # self.mbOptsGroup.pack(padx=10, pady=10, side=TOP) # svg import self.svgImportGroup = LabelFrame(self.nb, text="SVG Import", padx=5, pady=5) # wintopo options self.wtOptsGroup = LabelFrame(self.nb, text="WinTopo options", padx=5, pady=5) # self.wtOptsGroup.pack(padx=10, pady=10, side=TOP) # general options self.genOptsGroup = LabelFrame(self.nb, text="General options", padx=5, pady=5) # put tabs into notebook self.nb.add_screen(self.mbOptsGroup, "Potrace") self.nb.add_screen(self.wtOptsGroup, "WinTopo") activeTab = self.nb.add_screen(self.svgImportGroup, "SVG Import") self.nb.add_screen(self.genOptsGroup, "Options") self.nb.choice.set(0) activeTab.invoke() ########################### # potrace options # filter filtFrame = Frame(self.mbOptsGroup) filtFrame.pack(side=TOP, anchor=W) self.filtChk = Checkbutton(filtFrame, text="Filter", variable=botOptions.filterOn, command=self.filterCb) self.filtChk.pack(side=LEFT) self.filtValEnt = Entry(filtFrame, textvariable=botOptions.filterVal) self.filtValEnt.pack(side=LEFT) # blur blurFrame = Frame(self.mbOptsGroup) blurFrame.pack(side=TOP, anchor=W) self.blurChk = Checkbutton(blurFrame, text="Blur", variable=botOptions.blurOn, command=self.blurCb) self.blurChk.pack(side=LEFT, anchor=W) self.blurValEnt = Entry(blurFrame, textvariable=botOptions.blurVal) self.blurValEnt.pack(side=LEFT) # scale scaleFrame = Frame(self.mbOptsGroup) scaleFrame.pack(side=TOP, anchor=W) self.scaleChk = Checkbutton(scaleFrame, text="Scale", variable=botOptions.scaleOn, command=self.scaleCb) self.scaleChk.pack(side=LEFT, anchor=W) self.scaleValEnt = Entry(scaleFrame, textvariable=botOptions.scaleVal) self.scaleValEnt.pack(side=LEFT) # threshold threshFrame = Frame(self.mbOptsGroup) threshFrame.pack(side=TOP, anchor=W) self.threshChk = Checkbutton(threshFrame, text="Threshold", variable=botOptions.threshOn, command=self.threshCb) self.threshChk.pack(side=LEFT, anchor=W) self.threshValEnt = Entry(threshFrame, textvariable=botOptions.threshVal) self.threshValEnt.pack(side=LEFT) # interpolation interpFrame = Frame(self.mbOptsGroup) interpFrame.pack(side=TOP, anchor=W) self.linRad = Radiobutton(interpFrame, text="Linear Interpolation", variable=botOptions.interpolationType, value=1).pack(side=LEFT, anchor=W) self.cubRad = Radiobutton(interpFrame, text="Cubic Interpolation", variable=botOptions.interpolationType, value=2).pack(side=LEFT, anchor=W) # invert invFrame = Frame(self.mbOptsGroup) invFrame.pack(side=TOP, anchor=W) self.invertChk = Checkbutton(invFrame, text="Invert", variable=botOptions.invertOn) self.invertChk.pack(side=LEFT) ########################### # Wintopo options # despeckle WTdespecFrame = Frame(self.wtOptsGroup) WTdespecFrame.pack(side=TOP, anchor=W) self.WTdespecChk = Checkbutton(WTdespecFrame, text="Despeckle", variable=botOptions.WTDespecleOn, command=self.WTdespecCb) self.WTdespecChk.pack(side=LEFT) self.WTdespecValEnt = Entry(WTdespecFrame, textvariable=botOptions.WTDespecleVal) self.WTdespecValEnt.pack(side=LEFT) ########################### # SVG import # choose svg chooseSvgFrame = Frame(self.svgImportGroup) chooseSvgFrame.pack(side=TOP, anchor=W) self.chooseSVGFileBtn = Button(chooseSvgFrame, text="Choose SVG File", command=self.chooseSVGFile) self.chooseSVGFileBtn.pack(side=LEFT) self.svgFileLabelVar = StringVar() self.svgFileLabelVar.set("No file") self.svgFileLabel = Label(chooseSvgFrame, textvariable=self.svgFileLabelVar, justify=LEFT) self.svgFileLabel.pack(side=BOTTOM, fill=BOTH, anchor=SW) ########################### # General options # serial serialFrame = Frame(self.genOptsGroup) serialFrame.pack(side=TOP, anchor=W) self.serialOnChk = Checkbutton(serialFrame, text="Serial", variable=botOptions.serialOn, command=self.serialCtrlCb) self.serialOnChk.pack(side=LEFT) self.comValEnt = Entry(serialFrame, textvariable=botOptions.serialVal) self.comValEnt.pack(side=LEFT, fill=BOTH) # pen servo angles penAngleFrame = Frame(self.genOptsGroup) penAngleFrame.pack(side=TOP, anchor=W) self.penUpLabel = Label(penAngleFrame, text="Pen Up Angle: ") self.penUpLabel.pack(side=LEFT, fill=BOTH) self.penUpValEnt = Entry(penAngleFrame, textvariable=botOptions.penUpVal) self.penUpValEnt.pack(side=LEFT, fill=BOTH) self.penDownLabel = Label(penAngleFrame, text="Pen Down Angle: ") self.penDownLabel.pack(side=LEFT, fill=BOTH) self.penDownValEnt = Entry(penAngleFrame, textvariable=botOptions.penDownVal) self.penDownValEnt.pack(side=LEFT, fill=BOTH) # draw connecting lines when simulating robot drawing self.drawConnectChk = Checkbutton(self.genOptsGroup, text="Render Connecting Lines", variable=botOptions.renderConnectingOn) self.drawConnectChk.pack(side=TOP, anchor=W) ########################### # image windows imgFrame = Frame(master) imgFrame.pack(side=TOP, anchor=W) self.origImgWin = Canvas(imgFrame) self.procImgWin = Canvas(imgFrame) self.origImgWin.pack(side=LEFT, anchor=W) self.procImgWin.pack(side=LEFT, anchor=W) # get controls to take appropriate enabled/disabled state self.serialCtrlCb() self.filterCb() self.blurCb() self.scaleCb() self.threshCb() self.WTdespecCb()
self.active_fr.forget() fr.pack(fill=BOTH, expand=1) self.active_fr = fr # END ###------------------------------- # file: test.py # simple demonstration of the Tkinter notebook from Tkinter import * from notebook import * a = Tk() n = notebook(a, LEFT) # uses the notebook's frame f1 = Frame(n()) b1 = Button(f1, text="Button 1") e1 = Entry(f1) # pack your widgets before adding the frame # to the notebook (but not the frame itself)! b1.pack(fill=BOTH, expand=1) e1.pack(fill=BOTH, expand=1) f2 = Frame(n()) # this button destroys the 1st screen radiobutton b2 = Button(f2, text='Button 2', command=lambda:x1.destroy()) b3 = Button(f2, text='Beep 2', command=lambda:Tk.bell(a)) b2.pack(fill=BOTH, expand=1)
from Tkinter import * from notebook import * # make a toplevel with a notebook in it, with tabs on the left: root = Tk() nb = notebook(root, LEFT) # make a few diverse frames (panels), each using the NB as 'master': f1 = Frame(nb()) b1 = Button(f1, text="Button 1") e1 = Entry(f1) # pack your widgets in the frame before adding the frame to the # notebook, do NOT pack the frame itself! b1.pack(fill=BOTH, expand=1) e1.pack(fill=BOTH, expand=1) f2 = Frame(nb()) b2 = Button(f2, text='Button 2') b3 = Button(f2, text='Beep 2', command=Tk.bell) b2.pack(fill=BOTH, expand=1) b3.pack(fill=BOTH, expand=1) f3 = Frame(nb()) # add the frames as notebook 'screens' and run this GUI app nb.add_screen(f1, "Screen 1") nb.add_screen(f2, "Screen 2") nb.add_screen(f3, "dummy") root.mainloop()
Label1.pack(side=LEFT) textSingleFiles = Text(frame1,width=40,height=1) textSingleFiles.insert(INSERT,"") textSingleFiles.pack(side = LEFT) B1 = Tkinter.Button(frame1, text ="Browse", command = sel) B1.pack(side = LEFT) frame3= Frame(top) frame3.pack(side=TOP) scrollbar = Scrollbar(frame3) scrollbar.pack( side = RIGHT, fill=Y ) n = notebook(frame3) f1 = Frame(n()) # first page, which would get widgets gridded into it n.add_screen(f1, "All Information") text = Text(f1,width=80,height=40,yscrollcommand = scrollbar.set,fg="blue") text.tag_config("title", background="Cornflower Blue", foreground="black") text.tag_config("there", background="yellow", foreground="black") text.tag_config("badtitle", background="yellow", foreground="black") text.tag_config("subtitle", background="Lawn Green", foreground="black") text.tag_config("back", background="green", foreground="red") text.tag_config("main", background="Orange Red", foreground="black") text.tag_config("up", background="blue", foreground="red") text.tag_config("r2", background="red", foreground="blue") text.tag_config("r3", background="red", foreground="green")
def body(self, parent): import notebook notebook = notebook.notebook(parent, side=TOP) for group in self.opts: tab = Frame(notebook()) for optnumber, option in enumerate(group): optf = Frame(tab) label = Label(optf, text=getPrettyName(option)) label.pack(fill=Y, side=LEFT) if option.type in ('String', 'Integer', 'Password'): if option.type == 'Password': edit = Entry(optf, show='*') else: edit = Entry(optf) val = option.getValue() if val and val is not NoDefaultOption: edit.insert(0, str(val)) edit.pack(fill=BOTH, side=RIGHT) get = edit.get edit = (optf, label, edit) elif option.type == 'Choice': rbf = Frame(optf) buttons = [] name = option.name val = option.value self.choiceoptions[name] = val for c in [x.value for x in option]: if c == val: E = 1 else: E = 0 b = Radiobutton(rbf, text=c, indicatoron=1, variable=self.choiceoptions[name], value=c, command=lambda o=self.choiceoptions, n= name, c=c: o.__setitem__(n, c)) if E: b.select() else: b.deselect() b.pack(side=LEFT) buttons.append(b) rbf.pack(side=RIGHT, fill=BOTH) get = lambda opt=name: self.choiceoptions[opt] edit = (rbf, buttons) elif option.optionType == 'Boolean': name = option.name val = option.value self.booloptions[name] = val b = Checkbutton(optf, variable=self.booloptions[name], command=lambda o=self.booloptions, n=name: o.__setitem__(n, not o[n])) b.pack(side=RIGHT, fill=BOTH) edit = b get = lambda opt=name: self.booloptions[opt] else: raise ValueError, "unknown option type %s" % ( option.optionType) optf.pack(fill=X, side=TOP, ipady=4) if edit is not None: self.options[option.name] = (option.type, get, edit) notebook.add_screen(tab, group.name) return notebook()
def __init__(self, master): nb = notebook(master, TOP) tcframe = Frame(nb()) pframe = Frame(nb()) nb.add_screen(tcframe, "Terms and Courses") nb.add_screen(pframe, "Academic Programs") menubar = Menu(master) filemenu = Menu(menubar, tearoff=0) filemenu.add_command(label="Open") filemenu.add_command(label="Save", command=self.save) filemenu.add_separator() filemenu.add_command(label="Exit", command=root.quit) menubar.add_cascade(label="File", menu=filemenu) master.config(menu=menubar) Label(tcframe,text="Terms:").grid(row=0, column=0, columnspan=3) self.termlistscroll = Scrollbar(tcframe, orient=VERTICAL) self.termlist = Listbox(tcframe, exportselection=0, yscrollcommand=self.termlistscroll.set) self.termlistscroll.config(command=self.termlist.yview) self.termlistscroll.grid(row=1,column=2, sticky=N+S) self.termlist.grid(row=1, column=0, columnspan=2, sticky=N+S+E+W) self.termlist.bind('<Button-1>',lambda e: self.termlist.focus_set()) self.refreshTerms() addt = Button(tcframe, text="Add Term", command=self.addTerm).grid(row=2, column=0) delt = Button(tcframe, text="Delete Term", command=self.delTerm).grid(row=2, column=1) Label(tcframe,text="Courses:").grid(row=0, column=4, columnspan=4) self.courselistscroll = Scrollbar(tcframe, orient=VERTICAL) self.courselist = Listbox(tcframe, exportselection=0, yscrollcommand=self.courselistscroll.set) self.courselistscroll.config(command=self.courselist.yview) self.courselistscroll.grid(row=1, column=7, sticky=N+S) self.courselist.grid(row=1, column=4, columnspan=3, sticky=N+S+E+W) self.courselist.bind('<Button-1>',lambda e: self.courselist.focus_set()) self.currentTerm = None def poll(): if self.termlist.curselection(): now = self.termlist.get(self.termlist.curselection()) else: now = None if now is None: self.courselist.delete(0, END) elif now != self.currentTerm: self.currentTerm = now self.refreshCourses() self.courselist.after(250, poll) poll() addc = Button(tcframe, text="Add Course", command=self.addCourse).grid(row=2, column=4) delc = Button(tcframe, text="Delete Course", command=self.delCourse).grid(row=2, column=5) editc = Button(tcframe, text="Edit Course", command=self.editCourse).grid(row=2, column=6) self.statusbar = Label(tcframe, text="", bd=1, relief=SUNKEN, anchor=W) self.statusbar.grid(row=3, column=0, columnspan=7, sticky=E+W) self.currentCourse = None def pollCourse(): if self.courselist.curselection(): now = self.courselist.get(self.courselist.curselection()) else: now = None if now is None: self.statusbar.config(text="") elif now != self.currentTerm: self.currentCourse = now term = self.termlist.get(self.termlist.curselection()) try: self.statusbar.config( text=doc.xpath("//term[@date='"+term+ "']/course[@name='"+ self.currentCourse+"']/title/text()")[0]) except: self.statusbar.config(text="") self.courselist.after(250, pollCourse) pollCourse()