Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Tkinter, ttk
- class tv(ttk.Treeview):
- #----------------------------------------------------------------------
- def __init__(self, master, *args, **kwargs):
- """"""
- ttk.Treeview.__init__(self, master, *args, **kwargs)
- print 'root got focus?', master.focus_get()
- self.items = [ self.insert( '', 'end',
- text = str( i ) ) for i in range( 10 ) ]
- self['takefocus']= True
- self.selection_set(self.items[5])
- self.pack( fill = Tkinter.BOTH, expand = 1 )
- self.after(3000, self.focus_set)
- print 'just set focus', self.focus_set()
- print 'Treeview Focus set focus set? :', self.focus_get()
- print 'focus displayof', self.focus_displayof()
- #print 'selfs id', self.info()
- master.focus_set()
- print 'root got focus?', master.focus_get()
- self.bind('<Key>', self.callback)
- def callback(self, e):
- self.selection_set(self.items[2])
- print 'The TreeView Widget caught the key'
- root = Tkinter.Tk()
- root.config(takefocus=1)
- def callback(e):
- print 'root caught key'
- root.bind('<Key>', callback)
- root.focus_set()
- root.focus()
- list2 = tv(root)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment