First of all, the signal handler gets handed a different GtkButton
instance. There are technical reasons why I can't use the same python
object to refer to a widget all the time (its related to reference
counting).
Currently the mapping behaviour of GtkObjects is used to set and get
properties on an object/widget, the same as tkinter does.
The best way to store data for use in a callback is to use the set_data
and get_data methods:
wid.set_data('tag', data)
data = wid.get_data('tag')
Just as an idea, what would people think about using the __getattr__ and
__setattr__ functions to get and set widget data. This would require
altering the current __getattr__ routines to call their parent's
__getattr__ method for unknown attributes. This would fix most of the
wierdness people encounter in pygtk.
What do people think?
James Henstridge.
--
Email: [EMAIL PROTECTED]
WWW: http://www.daa.com.au/~james/
On Thu, 18 Feb 1999, David M. Cook wrote:
> I just noticed that the following raises an AttributeError:
>
> #silly illustrative example
>
> def button_click_cb(button):
> print button.name
>
> class MyButton(GtkButton):
>
> def __init__(self, name):
> GtkButton.__init__(self,name)
> self.name = name
>
> ...
> button = MyButton("Howdy!")
> button.connect("clicked", button_click_cb)
>
>
> while this does work:
>
> def button_click(button):
> print button['name']
>
> class MyButton(GtkButton):
>
> def __init__(self, name):
> GtkButton.__init__(self,name)
> self['name'] = name
>
> Is it possible to add support for the former?
>
> Dave
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
>
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]