Error: unbound method in Tkinter class

Peter Otten __peter__ at web.de
Sat Dec 9 12:28:54 EST 2006


Kevin Walzer wrote:

> I am trying to structure a Tkinter application with classes instead of
> just with simple functions, but I'm not sure how to call methods from my
> main class.
> 
> My main class is packetstreamApp(). Within that class I call various
> methods, including drawGUI() and authorizeDump(). My problem comes when
> I try to call authorizeDump from the Tkinter menu. Here is the code that
> calls authorizeDump():
> 
> self.packetmenu.add_command(label="Start Network Monitor",
> command=packetstreamApp.authorizeDump())

If that code is inside a method of packetstreamApp:

self.packetmenu.add_command(label="...", command=self.authorizeDump)

i. e. you have to pass a bound method (a method that knows about "its"
instance) and you must not call authorizeDump here (no trailing '()').

Of course I'm only guessing...

Peter



More information about the Python-list mailing list