_tkinter.TclError: can't set "PY_VAR0": invalid command name "-1210125972check"

Gregor Horvath g.horvath at gmx.at
Thu Mar 2 10:32:54 EST 2006


Hi,

I searched the web and docs but cannot figure out whats wrong with this 
code:

#!/usr/bin/python

import Tkinter as Tk

class testtk(Tk.Frame):

   def __init__(self):
     self.root = Tk.Tk()
     Tk.Frame.__init__(self,self.root)
     self.frame = Tk.Frame(self.root)
     self.var = Tk.StringVar()
     self.var.trace_variable('w',self.check)
     Tk.Entry(self.frame, textvariable = self.var).pack()
     self.frame.pack()
     Tk.mainloop()

   def check():
     pass

if __name__ == "__main__":
   t = testtk()
   t.var.set("TEST")

Result:

Traceback (most recent call last):
   File "<stdin>", line 22, in ?
   File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 191, in set
     return self._tk.globalsetvar(self._name, value)
_tkinter.TclError: can't set "PY_VAR0": invalid command name 
"-1210125972check"


Any ideas, why I cant set the variable var?

--
Greg



More information about the Python-list mailing list