I believe you need something like 'def do_something(self, button)'
instead.  Pygtk sends the objref to the button to your callback as 
well.

One way to debug this kind of thing is to define like this:

def xxx(self, *args):
  'print args'

(*args param becomes a tuple of all remaining args passed).

Then you can see what is being sent and can adjust accordingly... I have
this problem all the time and use this technique since I haven't found
clear documentation and I'm too lazy to look at the source!

- Stephan

------------------------------

On Wed, 26 Jan 2000, [ISO-8859-1] Dirk H�sken wrote:

> 
> I'm new to pygtk and I'm trying to figure out why I can't connect a
> signal to a class method from within the class?
> 
> I'm trying to execute the following code:
> 
> 
> from gtk import *
> 
> class SomeClass:
>       def init_widgets(self):
>               w = GtkWindow()
>               w.connect("delete_event", mainquit)
>               b = GtkButton(label=" Foo ")
>               b.connect("clicked", self.do_something)
>               w.add(b)
>               b.show()
>               w.show()
>       def do_something(self):
>               print "wowie-zowie"
>       def __init__(self):
>               self.init_widgets()
>               mainloop()
> 
> if __name__=="__main__":
>       x = SomeClass()
> 
> 
> but Python spits this at me when I push the button:
> TypeError: too many arguments; expected 1, got 2
> 
> It all works if I move the code from a class to "plain" Python.
> I'm using Python 1.5.2, pygtk 0.6.3, gtk+-1.2.5 on a Debian 2.1.
> Is this normal behavior? I believe not. Does anybody know how I can
> work around this? Or did I miss something?
> 
> TIA,
>       Dirk
> 
> -- 
> Dirk H�sken
> :wq
> 
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
> 

To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Reply via email to