By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,898 Members | 1,162 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,898 IT Pros & Developers. It's quick & easy.

tkinter and textvariable option

P: n/a
hello everybody.

i am a a bit of a newbie in python/tkinter,and i am experimenting a bit
with widgets like checkbuttons.

in python, you can create a checkbutton instance like this:

.....
self.tergicristalli = IntVar()
self.b1 = Checkbutton(self.pulsanti_spunta)
self.b1.configure(
text = "Tergicristalli a posto",
variable = self.tergicristalli ### (1)
)
self.b1.pack()
.....

where you bind the widget to a variable 'self.tergicristalli', which
will be updated as the user checks/unchecks the checkbutton.

maybe i interpret the question incorrectly, but the syntax (1) seems
like assigning the *value* of 'self.tergicristalli' to the variable
variable, while it is more like an aliasing instead...

my question is: how can i embed the above code inside a function body,
such that the function accepts as a parameter the variable to bind the
option 'variable' to (not the value, mind you!)? like this:

def acceptName(name):
....
self.tergicristalli = IntVar()
self.b1 = Checkbutton(self.pulsanti_spunta)
self.b1.configure(
text = "Tergicristalli a posto",
variable = name ### <<<--- THIS IS NOT WHAT I MEAN, OF COURSE!
)
self.b1.pack()
....

bye bye

macs
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.