Tkinter menu checkbutton not working
Dodo
dodo_do_not_wake_up at yahoo.Fr
Wed Jun 9 13:20:46 EDT 2010
More information about the Python-list mailing list
Wed Jun 9 13:20:46 EDT 2010
- Previous message (by thread): Tkinter menu checkbutton not working
- Next message (by thread): Tkinter menu checkbutton not working
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Le 09/06/2010 18:54, rantingrick a écrit : > On Jun 9, 11:26 am, Dodo<dodo_do_not_wake... at yahoo.Fr> wrote: >> Hello, >> >> I trying to make this piece of code work (this is python3) >> >> from tkinter import * >> from tkinter.ttk import * >> >> class Window: >> def __init__(self): >> self.root = Tk() >> >> self.menu = Menu(self.root) >> self.root['menu'] = self.menu >> >> self.submenu = Menu(self.menu) >> self.ck = 0 >> self.submenu.add_checkbutton(label="My checkbutton", >> variable=self.ck, command=self.displayCK) >> self.menu.add_cascade(label="sub", menu=self.submenu ) >> >> def displayCK(self): >> print( self.ck ) >> >> app = Window() >> app.root.mainloop() > > > see my recent post on your last question. The way you are writing > these classes is wrong. Always inherit from something, in this case > Tk. Fix that first and then pretty up this GUI. But to answer your > question "self.ck" needs to be an instance of tk.IntVar. Read more > about it here... > > http://infohost.nmt.edu/tcc/help/pubs/tkinter/checkbutton.html I already tried with self.ck = IntVar() and now it displays PY_VAR0 FYI, I'm using Thunderbird 3, which appears to have some bugs with indentation (according to Alf P. Steinbach). That's why I replaced \t by a single space
- Previous message (by thread): Tkinter menu checkbutton not working
- Next message (by thread): Tkinter menu checkbutton not working
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list