TKinter Question
Neal Norwitz
neal at metaslash.com
Thu Mar 21 17:27:26 EST 2002
> Paul Sage wrote:
>
> Hi all. I am new to the list; the impetus for my signing up is a roadblock. J
>
> I am currently working with a quick and dirty little App for learning Python. I am using Tkinter because the app
> really needs a GUI.
>
> Global variables within the module:
>
> pointsAvailable = 5
>
> currentPointsToSpend = "Current Points left to spend: %s"%pointsAvailable
>
> Inside the class definition of an object that is the GUI window:
>
> self.pointsLeftToSpend = Label(root, relief = RIDGE, borderwidth = 1,
>
> anchor = N, justify=CENTER,
>
> textvariable = currentPointsToSpend).pack()
>
> My problem is with textvariable. No matter what I seem to do, it just won¡¯t show up. Is this because it falls out
> of scope somehow?
No, textvariable needs to be a Tcl/Tk 'textvariable', ie, StringVar.
Try this:
currentPointsToSpend = StringVar()
currentPointsToSpend.set("Current Points ... %s"%pointsAvailable)
Neal
More information about the Python-list
mailing list