/Demo/tix/grid.py

http://unladen-swallow.googlecode.com/ · Python · 28 lines · 21 code · 6 blank · 1 comment · 2 complexity · edc381de3aa77e380d91ba95320c715f MD5 · raw file

  1. ###
  2. import Tix as tk
  3. from pprint import pprint
  4. r= tk.Tk()
  5. r.title("test")
  6. l=tk.Label(r, name="a_label")
  7. l.pack()
  8. class MyGrid(tk.Grid):
  9. def __init__(self, *args, **kwargs):
  10. kwargs['editnotify']= self.editnotify
  11. tk.Grid.__init__(self, *args, **kwargs)
  12. def editnotify(self, x, y):
  13. return True
  14. g = MyGrid(r, name="a_grid",
  15. selectunit="cell")
  16. g.pack(fill=tk.BOTH)
  17. for x in xrange(5):
  18. for y in xrange(5):
  19. g.set(x,y,text=str((x,y)))
  20. c = tk.Button(r, text="Close", command=r.destroy)
  21. c.pack()
  22. tk.mainloop()