Error: unbound method in Tkinter class

Kevin Walzer kw at codebykevin.com
Sat Dec 9 12:17:19 EST 2006


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())

Here is the code for authorizeDump():

 def authorizeDump(self):
	##do stuff here

And here is the error message that comes when I try to call authorizeDump():

Traceback (most recent call last):
  File "/Users/kevin/Programming/packetstream/packetstream-classes.py",
line 257, in <module>
    app = packetstreamApp()
  File "/Users/kevin/Programming/packetstream/packetstream-classes.py",
line 19, in __init__
    self.drawGUI()
  File "/Users/kevin/Programming/packetstream/packetstream-classes.py",
line 49, in drawGUI
    self.packetmenu.add_command(label="Start Network Monitor",
command=packetstreamApp.authorizeDump())
TypeError: unbound method authorizeDump() must be called with
packetstreamApp instance as first argument (got nothing instead)

I don't know how to interpret this error message, and so can't implement
a fix. Can anyone shed light on what I'm doing wrong?

Thanks.

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com



More information about the Python-list mailing list