tkinter and textvariable option

M

max(01)*

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,044
Latest member
RonaldNen

Latest Threads

Top