[Glade-users] callbacks and signals from GtkOptionMenu?



I'm using Python 1.5.2, gnome-python-1.0.53, libgtk+1.2.8 with
glade-0.5.11 and libglade-0.14 on Redhat 6.2.

I've used 'glade' to build a user interface.  My application has a
GtkOptionMenu (called 'filter_option') with three items.  I want to
attach handlers that will be called when one of the menu items is
selected so my Python application can react to the user's choices. 

Unfortunately, I don't see how to do this. Glade is creating three
GtkMenuItem's associated with a GtkMenu.  But how do I retrieve the
GtkMenuItem for a given choice?  If I could retrieve each of the
GtkMenuItem's, I could attach to the 'activate' signal on each.

I have attached to the 'selection-done' signal of the GtkMenu, but since
I don't know the text associated with the selected GtkMenuItem, it
doesn't help:

optionmenu = self.wtree.get_widget('filter_menu')
theMenu = optionmenu.get_menu()
theMenu.connect('selection-done', self.filter_menu_cb)


def filter_menu_cb(self, me ):
        print 'filter_menu: button released', me, me.get_active() 

# this yields:
filter_menu: button released <gtk.GtkMenu instance at 837df48>
<gtk.GtkMenuItem instance at 8379f28>

Bottom line - how do I retrieve the GtkMenuItem widgets for the items
automatically built by Glade for a GtkOptionMenu?   (Or, how do I
determine the text associated with the 'active' GtkMenuItem after the
'selection-done' signal occurs?)

Thanks much!


--
Joe VanAndel              
National Center for Atmospheric Research
http://www.atd.ucar.edu/~vanandel/
Internet: vanandel ucar edu





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]