[pygtk] UIManager and MenuToolButton

Don Allingham dallingham at users.sourceforge.net
Wed Jan 11 04:17:03 WST 2006


 From what I can tell, UIManager has no direct support for 
MenuToolButton, which was a big disappointment to me.  I have been able 
to work around this with a bit of a hack. This hack works well when your 
button position is stationary, but fails if your buttons are more 
dynamic (if you add and remove ui's and action groups).

This is what we do to attach an Open/OpenRecent menutoolbutton. The menu 
already exists in the ui xml description.

# create the MenuToolButton

openbtn = gtk.MenuToolButton(gtk.STOCK_OPEN)
openbtn.show()
openbtn.connect('clicked',self.open_activate)

# extract openrecent menu from the uimanager

menu_item = self.uimanager.get_widget('/MenuBar/FileMenu/OpenRecent')

# set the menu on the menutoolbutton to the extracted menu
openbtn.set_menu(menu_item.get_submenu())

# find the toolbar from the uimanager and insert the button
# at the fixed location

toolbar = self.uimanager.get_widget('/ToolBar')
toolbar.insert(openbtn,1)

Don


Mystilleef wrote:
> Hello,
> 
> Is there an obvious way to add a MenuToolButton to Toolbar
> using UIManager?
> 
> Thanks
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



More information about the pygtk mailing list