someinternetuser

Simple tkinter program

Feb 22nd, 2013
99
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from Tkinter import *
  2.  
  3. class MyClass:
  4.     def __init__(self, parent):
  5.         self.myParent = parent
  6.         self.portVar = IntVar()
  7.         self.portVar.set(111)
  8.  
  9.         port_validator = self.myParent.register(self._validate)
  10.  
  11.         self.myEntry = Entry(self.myParent, width=9, textvariable=self.portVar,
  12.             validate='all', validatecommand=(port_validator,'%d', '%i', '%P', '%s', '%S', '%v', '%V', '%W'))
  13.  
  14.         self.myEntry.pack(side=TOP)
  15.  
  16.  
  17.     def _validate(self, d, i, P, s, S, v, V, W):
  18.         print "OnValidate: d='%s' i='%s' P='%s' s='%s' S='%s' v='%s' V='%s' W='%s'" % (d, i, P, s, S, v, V, W)
  19.         return P.isdigit()
  20.  
  21.  
  22. root = Tk()
  23. myclass = MyClass(root)
  24. root.mainloop()
RAW Paste Data