Tk variables problem
David Fisher
python at rose164.wuh.wustl.edu
Wed Feb 2 08:50:05 EST 2000
>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<
On 2/2/00, 7:10:50 AM, "Sven Drescher" <Sven.Drescher at dlr.de> wrote
regarding Tk variables problem:
> Hi!
> I cannot understand why the following little program doesn't work
correct.
> It's surely a little problem, but in my program are more situations,
where
> such an error is raised.
> I thought, there isn't a problem, but...
> Tanks for hints, what I did wrong.
> Sven
> e.g.:
> #!/usr/.../python
> import Tkinter
> class test:
> def __init__(self):
> self._bool=Tkinter.BooleanVar()
> self._bool.set(1)
> self.display()
> def display(self):
> print "Hi!"
> print "The value is ", self._bool.get()
> a=test()
> a.hallo()
> error:
> Variable.__init__(self, master)
> self._tk = master.tk
> Attribute Error: 'None' object has no attribute 'tk'
> ...
you need to instantiate a root window, like this:
root = Tkinter.Tk()
before you make the call to Tkinter.BooleanVar().
David Fisher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20000202/cdab38b5/attachment.html>
More information about the Python-list
mailing list