[Tutor] Problem with IntVar() - Oops! Here's the code.
Ronnie Betzen
ron at frenchmerchants.net
Sat Mar 5 03:52:02 CET 2005
#! /usr/bin/env python
import Tkinter
class timer:
def __init__(self):
# initialize global variables
self.ckbuttonstatus = IntVar()
# set up main window
self.top = Tk()
self.top.geometry('355x125')
self.top.title(appname)
self.top.resizable(width='no', height='no')
# set up menubar
self.menubar = menu(self.top)
self.top.config(menu = self.menubar)
# set up file menu
self.filemenu = Menu(self.menubar, tearoff = 0)
self.filemenu.add_cascade(label="File", menu=self.filemenu)
self.filemenu.add_checkbutton(label = "Click Me!", command =
self.labelUpdate)
self.filemenu.add_command(label = "Quit", command=self.top.quit)
# set up main display area
self.frame = Frame(self.top)
self.frame.pack(fill=x)
self.displaylabel=Label(self.frame, text=" ", font="Times 36 bold",
relief="sunken")
self.displaylabel.pack(side=BOTTOM, fill=X)
def labelUpdate(self):
self.status = self.ckbuttonstatus.get()
self.labeltext = "Chekbutton status is: " + self.status
self.displaylabel.config(text=labeltext)
self.top.update()
if __name__ == '__main__':
mainApp = timer()
mainloop()
On Friday 04 March 2005 08:39 pm, Ronnie Betzen wrote:
> I've been trying to use IntVar() to update checkboxes using the Tkinter
> toolkit. To date I haven't been successful getting it to work. Evidently
> I'm missing some concept with regards to setting up my interface. I've
> successfully run scripts by other people using IntVar() so I know my
> personal system is ok.
>
> Here is some code that causes me problems with IntVar(). Can someone
> enlighten this total newbie (python and programming both.) as to what I'm
> missing here?
>
> Thanks,
>
> Ron
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list