Tkinter-helper-gui and a main class: their communication
Greg Krohn
gkrohn at tcq.net
Thu May 2 03:59:07 EDT 2002
[snip]
> class Turtle:
> def __init__(self):
> try:
> gui = Turtle_gui()
> print "I am trying ..."
> except Buttonpush, e:
> buttonwork()
> def buttonwork(self):
> print "main class Turtle sees the The ButtonPush exception"
> # do something useful with this knowledge
>
> turtle = Turtle()
> root.mainloop()
First of all, I am no Tkinter expert so [a]some, [b]none or [c]all of this
may be incorrect.
The try..except block that catches the ButtonPush only exsists in __init__.
The button
push event happens in a loop in root.mainloop()--after the Turtle object
exsists--outside
of __init__.
Is there a reason you are using exceptions to catch the button push event?
It seems sort of
convoluted to me. I wonder if you could use a callback instead to
communicate between the classes.
hoping for [a] or [b]
greg
More information about the Python-list
mailing list