hello.

the following code:

      1 from Tkinter import *
      2
      3 class MiaApp:
      4   def __init__(self, genitore):
      5     self.mioGenitore = genitore
      6     self.i = IntVar()
      7     self.i.set(42)
      8     self.s = StringVar()
      9     self.s.set("Baobab")
     10     self.lab = {}
     11     self.lab["self.i"] = Label(self.mioGenitore)
     12     self.lab["self.i"].configure(width = 30, relief = RIDGE,
     13       text = "[vuota]")
     14     self.lab["self.i"].pack()
     15     self.lab["self.s"] = Label(self.mioGenitore)
     16     self.lab["self.s"].configure(width = 30, relief = RIDGE,
     17       text = "[vuota]")
     18     self.lab["self.s"].pack()
     19     self.but = Button(self.mioGenitore)
     20     self.but.configure(text = "Vai!", command = self.procedi)
     21     self.but.pack()
     22   def procedi(self):
     23     for var in ("self.i", "self.s"):
     24       self.lab[var].configure(textvariable = var)
     25
     26 radice = Tk()
     27 miaApp = MiaApp(radice)
     28 radice.mainloop()

is intended to make a window with 2 labels and a button, such that pressin the button you get the labels display the content of two variables. it does not work, of course, as intended. is there anybody who can point me in the right direction? (the problem seems to be that the command option wants a variable name, not a string containing that name).

hopefully

macs
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to