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()
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