On Thu, 2007-03-08 at 11:00 +0100, Geoff Bache wrote:
> Hello,
> 
> I'm wondering about defining a menu structure using gtk.UIManager and an 
> XML file. What confuses
> me a bit is that it seems to be necessary to define which menus and 
> submenus I have in the Python code,
> even if I can then control their contents from XML. The reason seems to 
> be that everything has to have
> an "action".
> 
> I define a menu like this:
> 
> <menu action="actionsmenu">
>       <menuitem action="Select"/>
>       <menuitem action="Run"/>
> </menu>
> 
> But for this to work I have to write (somewhere in my Python code)
> 
> menuAction = gtk.Action("actionsmenu", "_Actions", None, None)
> ...
> 
> just in order to translate the identifier "actionsmenu" into the label 
> "_Actions".
> 
> I'd like to be able to write something like
> 
> <menu label="_Actions>
> 
> so that I can define the whole menu structure in one format in one 
> place. Is this possible in some way?

I don't believe it's possible and for good reason. A major
benefit/feature of UIManger is making actions independent of any given
widget, e.g. a menu item. When the notion of separated actions and
widgets introduced you can then combine them at will without having to
keep multiple widgets in sync. One reason I switched to UIManager was
the all too common scenario where an icon or label was modified in one
part of the UI but other parts of the UI (e.g. the same item in a popup
menu or a toolbar button) was forgotten about in the update leading to
inconsistencies in the UI. I really like the fact I change the
definition in exactly one place and every part of the UI is consistently
updated. That flexibility and consistency occurs because actions and
widgets are independent.
-- 
John Dennis <[EMAIL PROTECTED]>

Learn. Network. Experience open source.
Red Hat Summit San Diego  |  May 9-11, 2007
Learn more: http://www.redhat.com/promo/summit/2007


_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to