You need to create an instance of Tkinter.Tk
before you create one of Tkinter.StringVar
:
root = Tk() # You must do this first
p = StringVar()
Below is a demonstration:
>>> from Tkinter import *
>>>
>>> p = StringVar()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\lib-tk\Tkinter.py", line 287, in __init__
Variable.__init__(self, master, value, name)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 218, in __init__
self._tk = master.tk
AttributeError: 'NoneType' object has no attribute 'tk'
>>>
>>> root = Tk()
>>> p = StringVar()
>>>