[Sugar-devel] gtk.RadioToolButton active property not recognized

James Cameron quozl at laptop.org
Wed May 18 20:30:39 EDT 2011


On Sat, May 14, 2011 at 11:51:05AM +0200, laurent bernabe wrote:
>   * in my application, i'm using two gtk.RadioToolButton

Looking at your source code, and simplifying it for discussion, you do
this:

def add():
    foo = gtk.RadioToolButton(None, gtk.STOCK_MEDIA_RECORD)
    foo.set_active(True)
    foo.connect("clicked", bar)

def bar(foo):
    if foo.get_active():
	...

>   * the "clicked" handlers of the two RadioToolButton test the active
>   property of the event source (so, the RadioToolButton itself)

The "clicked" signal name is not in RadioToolButton widget class but in
ancestor widget class ToolButton.  I don't think that is the problem,
but I mention it for clarity.

For simplicity one might use the "toggled" signal of the less distant
ancestor class ToggleToolButton.

I suggest you try using "toggled" ... which would require a different
signal function.

>   * but the SugarOLPC image logs reports me the error "
>   'gtk.RadioToolButton' has no attribute 'active' "

It is as if the "active" attribute has been removed by the initialiser
of the higher class.

>   * however, the PyGTK reference manual says that 'active' is a
>   property of gtk.ToggleToolButton, from which RadioToolButton is
>   inherited and therefore, handlers are not properly executed

Yes, and this is only available in GTK+ 2.8 and above.  I'm sure you'll
eventually work out what version you are using.

If it still does not work, then it sounds like a PyGTK or GTK+ bug that
you might raise with those projects ... after checking to see if it is
fixed in the latest versions.  Otherwise, try using "toggled" and see if
it works.

-- 
James Cameron
http://quozl.linux.org.au/


More information about the Sugar-devel mailing list