Dynamically changing button text in python

Fredrik Lundh fredrik at pythonware.com
Sun Jan 15 05:44:24 EST 2006


marijuanated at gmail.com wrote:

> The problem is once i set the textvariable property of the button,i
> cannot change the text.For example,
>
> curButton = Button(root,text="Stop Server",textvariable="this")

what made you think that setting textvariable to "this" would be a good
idea?

the textvariable option is used to specify a Tkinter variable that's used
to control the button text; e.g.

    curVar = Tkinter.StringVar()
    curButton = Button(root, textvariable=curVar)

    curVar.set("new text")

also see

    http://effbot.org/tkinterbook/button.htm
    http://effbot.org/tkinterbook/variable.htm

</F>






More information about the Python-list mailing list