It looks like you are doing the design part right -- having a stand-alone
function to deal with all the diff. widgets you want to handle.
The thing is, python is giving the widget to your handler as an argument.
Change the definition to:
"def sendkey( widget, data ):"
and you should be fine.
The 'data' argument is any data that you wanted the signal to pass to your
handler and is specified when you connect the handler to the signal.
-D
On Fri, 29 Sep 2000 10:56:51 Dave Belfer-Shevett wrote:
> On Fri, 29 Sep 2000, James Henstridge wrote:
> > > Can you give me a quick code example?
> > If you just want to do something special for a particular widget, then
> > using the key_press_event signal is the correct aproach. You look at the
> > attributes of the event object to see which key was pressed. Return TRUE
> > if you handled the event yourself, and FALSE otherwise.
>
> Okay, that makes a lot of sense, but I"m having problems wrapping the
> event trigger. (sp_sendtext is a gtktext widget)
>
> ta = widgets.get_widget('sp_sendtext')
> ta.signal_connect('key_press_event',sendkey)
>
> Which triggers
>
> def sendkey():
> print "Key pressed! "
> return FALSE
>
> But I get:
>
> [shevett@cheetah]:~/python/spanker/proj1$ ./spanker.py
> Traceback (innermost last):
> File "/usr/local/lib/python1.5/site-packages/gtk.py", line 125, in
> __call__
> ret = apply(self.func, a)
> TypeError: no arguments expected
>
> Wha'd i do wrong?
>
> Also, could you point me to the structure of an event object?
>
> -------------------. Web-based problem management: www.stonekeep.com
> Dave Belfer-Shevett >----------------------------------------------------.
> [EMAIL PROTECTED] / Don't byte off more than you can view. (Maxims for \
> ------------------< the Internet Age) |
> \______________________________________________________/
>
>
> _______________________________________________
> pygtk mailing list [EMAIL PROTECTED]
> http://www.daa.com.au/mailman/listinfo/pygtk
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk