I am trying to write a VERY simple user interface in Python using Tkinter. I ran into a little problem with the StringVar class. The thing is, when I run the python script, I get an error message in the line initializing the StringVar variable. I wrote an example program with this problem that I would like to get:
from Tkinter import * var = StringVar() var.set('test');
When I run it through python, I see this error:
$ python test.py Traceback (most recent call last): File "test.py", line 3, in <module> var = StringVar() File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 254, in __init__ Variable.__init__(self, master, value, name) File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 185, in __init__ self._tk = master.tk AttributeError: 'NoneType' object has no attribute 'tk' Exception AttributeError: "StringVar instance has no attribute '_tk'" in <bound method StringVar.__del__ of <Tkinter.StringVar instance at 0xb73cc80c>> ignored
I have the feeling that this is a problem with my Python installation, but maybe I am doing something wrong? I am using python version 2.6.5 on Ubuntu Linux, if that matters.
source share