def sample_test(): from Tix import Tk, Label, Button def test_cmd(event): if event.i == 0: return '%i, %i' % (event.r, event.c) else: return 'set' def browsecmd(event): print "event:", event.__dict__ print "curselection:", test.curselection() print "active cell index:", test.index('active') print "active:", test.index('active', 'row') print "anchor:", test.index('anchor', 'row') root = Tk() var = ArrayVar(root) for y in range(-1, 4): for x in range(-1, 5): index = "%i,%i" % (y, x) var.set(index, index) label = Label(root, text="Proof-of-existence test for Tktable") label.pack(side = 'top', fill = 'x') quit = Button(root, text="QUIT", command=root.destroy) quit.pack(side = 'bottom', fill = 'x') test = Table(root, rows=10, cols=5, state='disabled', width=6, height=6, titlerows=1, titlecols=1, roworigin=-1, colorigin=-1, selectmode='browse', selecttype='row', rowstretch='unset', colstretch='last', browsecmd=browsecmd, flashmode='on', variable=var, usecommand=0, command=test_cmd) test.pack(expand=1, fill='both') test.tag_configure('sel', background = 'yellow') test.tag_configure('active', background = 'blue') test.tag_configure('title', anchor='w', bg='red', relief='sunken') root.mainloop()
#!/usr/bin/env python from Tkinter import Label, Button, END from Tix import Tk, Control, ComboBox top = Tk() top.tk.eval('package require Tix') lb = Label(top, text='Animals (in pairs; min: pair, max: dozen)') lb.pack() ct = Control(top, label='Number;', integer=True, max=12, min=2, value=2, step=2) ct.label.config(font='Helvetice -14 bold') ct.pack() cb = ComboBox(top, label='Type:', editable=True) for animal in ('dog', 'cat', 'hamster', 'python'): cb.insert(END, animal) cb.pack() qb = Button(top, text='QUIT', command=top.quit, bg='red', fg='white') qb.pack() top.mainloop()
except Exception,inst: self.updateResults(inst,numOfEigenfaces) def recogniseFace(self,imagefilenames,selectedFileName,selectedDirectory,numOfEigenfaces,thresholdVal): self.facerec.checkCache(selectedDirectory,imagefilenames,numOfEigenfaces) mindist,matchfile=self.facerec.findMatchingImage(selectedFileName,numOfEigenfaces,thresholdVal) self.processMatchResult(matchfile,mindist,numOfEigenfaces) def processMatchResult(self,matchfile,mindist,numOfEigenfaces): if not matchfile: error=pyeigenfaces.NoMatchError('No match! try higher threshold') self.updateResults(error,numOfEigenfaces) else: print "processMatchResult()::matches :"+matchfile+" dist :"+str(mindist)# self.updateResults(None,numOfEigenfaces,matchfile,mindist) def updateResults(self,error,numOfEigenfaces=0,matchfile='',mindist=0.0): self.myapp.updateDisplay(error,numOfEigenfaces,matchfile,mindist) if __name__ == "__main__": controller=PyFaceController() root = Tk() root.wm_title("PyFaces") controller.myapp =pyfacesgui.PyFaceUI(root,controller) root.mainloop()
from Tkinter import Label, Button, END from Tix import Tk, Control, ComboBox top = Tk() top.tk.eval('package require Tix') lb = Label(top, text='Animals (in pairs; min: pair, max: dozen)') lb.pack() ct = Control(top, label='Number:', integer=True, max=12, min=2, value=2, step=1) ct.label.config(font='Helvetica -14 bold') ct.pack() cb = ComboBox(top, label='Type:', editable=True) for animal in ('dog', 'cat', 'hamster', 'python'): cb.insert(END, animal) cb.pack() qb = Button(top, text='QUIT', command=top.quit, bg='red', fg='white') qb.pack() top.mainloop()
self.updateResults(inst,numOfEigenfaces) def recogniseFace(self,imagefilenames,selectedFileName,selectedDirectory,numOfEigenfaces,thresholdVal): self.facerec.checkCache(selectedDirectory,imagefilenames,numOfEigenfaces) mindist,matchfile=self.facerec.findMatchingImage(selectedFileName,numOfEigenfaces,thresholdVal) self.processMatchResult(matchfile,mindist,numOfEigenfaces) def processMatchResult(self,matchfile,mindist,numOfEigenfaces): if not matchfile: #error=pyeigenfaces.NoMatchError('No match! try higher threshold') error=pyeigenfaces.NoMatchError('No hay resultados! intente con threshold mas alto') self.updateResults(error,numOfEigenfaces) else: print "processMatchResult()::matches :"+matchfile+" dist :"+str(mindist)# self.updateResults(None,numOfEigenfaces,matchfile,mindist) def updateResults(self,error,numOfEigenfaces=0,matchfile='',mindist=0.0): self.myapp.updateDisplay(error,numOfEigenfaces,matchfile,mindist) if __name__ == "__main__": controller=PyFaceController() root = Tk() root.wm_title("Reconocimientos de Rostros en Raspberry Pi") controller.myapp =pyfacesgui.PyFaceUI(root,controller) root.mainloop()
from Tix import Tk from Tkinter import Frame, Button, Label, Menu from _tkinter import mainloop from tkMessageBox import showinfo, showerror, askyesno import oxo_logic top = Tk() def buildMenu(parent): menus = ( ("File", (("New", evNew), ("Resume", evResume), ("Save", evSave), ("Exit", evExit))), ("Help", (("Help", evHelp), ("About", evAbout))) ) menubar = Menu(parent) for menu in menus: m = Menu(parent) for item in menu[1]: m.add_command(label=item[0], command=item[1]) menubar.add_cascade(label=menu[0], menu=m) return menubar def evNew(): status['text'] = 'Playing Game' game2cells(oxo_logic.newGame())
REGU = "regu" SIGNS = { "please be c a r e f u l ": WARN, "very d a n g e r o u s ": CRIT, "have fun": REGU, "help help": WARN, "nice job": REGU } action_warn = lambda: showwarning(WARN, WARN + " pressed") action_crit = lambda: showerror(CRIT, CRIT + " pressed") action_regu = lambda: showinfo(REGU, REGU + " pressed") action_INFO = lambda: showinfo(REGU, "whatever you want,whatever you do,it works!") top = Tk() top.iconbitmap('App.ico') # image = it.PhotoImage(file="GIF2.gif") Button(top, text='chose one to see what may happened', command=action_INFO, compound='right', bg='green', fg='white', bitmap='info', padx=10, pady=10).pack() builderButton = partial(Button, top) WarnButton = partial(builderButton,
import math import random import string import this import time from Tix import Tk import sys print dir(math) print math.__name__, math.__doc__ words = "hello world how are you " print words.split() print string.split(words) print dir(random) print random.randint(1, 9) print dir(time) print time.asctime() print time.gmtime(20) print time.timezone print time.time() window = Tk() #this will make a prompt window window.mainloop() print sys.argv
self.namedtraces[name] = cbname return cbname def delete_named(self, name): if name in self.namedtraces: cbname = self.namedtraces[name] self.trace_vdelete('w',cbname) #self._tk.call("trace","vdelete",self._name,'w',cbname) print "FancyDoubleVar: successfully deleted trace named %s" % name else: print "FancyDoubleVar: attempted to delete named %s which wasn't set to any function" % name def get_selection(listbox): 'Given a listbox, returns first selection as integer' selection = int(listbox.curselection()[0]) # blech return selection if __name__=='__main__': root=Tk() root.tk_focusFollowsMouse() iv=IntVar() def cb(): print "cb!" t = Togglebutton(root,text="testbutton",command=cb,variable=iv) t.pack() Entry(root,textvariable=iv).pack() root.mainloop()
print "Process %s" % self.s1.get() def e1_callback(self, event): print "e1_callback", "%s" % event import tkFileDialog filename = tkFileDialog.askopenfilename() if filename: self.s1.set(filename) ######################################################################## if __name__ == "__main__": from Tix import Tk root = Tk() root.title("Run quint .gpx processing") root.geometry("450x300+200+200") # root.minsize(400, 200) master = ttk.Frame(root, padding=(3, 3, 12, 12)) master.grid(column=0, row=0, sticky=(Tkconstants.N, Tkconstants.E, Tkconstants.S, Tkconstants.W)) app = App(master) root.config(menu=app.menubar) for child in master.winfo_children(): child.grid_configure(padx=5, pady=5)