On 08-09-10 09:51, Alessandro Dentella wrote:
here is the code that shows what I mean. The action 'Test' has a tooltip in
the ToolButton and not in the meny entry:

thanks in advance for any possible hint/explanation
Connect the uimanager to the connect-proxy signal, there you can set tooltips to the menuitems.
See in-code for a working implementation.

Note: this maybe can be easier, I just modified it from my code where I show a statusbar message when the mousepointer goes over the menuitems.

Cheers,
Timo

import gtk

GENERAL_UI = '''
   <menubar name="Main">
      <menu action="File">
         <menuitem action="Test"/>
     </menu>
   </menubar>
   <toolbar name="TbMain">
      <toolitem action="Test"/>
   </toolbar>
  '''

class Test(object):

     def __init__(self):
         w = gtk.Window()
         h = gtk.VBox()
         w.add(h)

         actions = gtk.ActionGroup('test')
         actions.add_actions([
             ('File', None, 'FILE'),
             ('Test', gtk.STOCK_ABOUT, 'Test name', None, 'Tooltip for test', 
self.debug),
             ])

         ui_manager = gtk.UIManager()
        ui_manager.connect('connect-proxy', self.uimanager_connect_proxy)
         ui_manager.add_ui_from_string(GENERAL_UI)
         ui_manager.insert_action_group(actions)

         menu    = ui_manager.get_widget('/Main')
         toolbar = ui_manager.get_widget('/TbMain')

         h.add(menu)
         h.add(toolbar)
         w.resize(200, 60)
         w.show_all()
    def uimanager_connect_proxy(self, uimgr, action, widget):
        tooltip = action.get_property('tooltip')
        if isinstance(widget, gtk.MenuItem) and tooltip:
            widget.set_tooltip_text(tooltip)
     def debug(self, action):
         print action

t = Test()

gtk.main()


On Wed, Sep 08, 2010 at 09:26:52AM +0200, Alessandro Dentella wrote:
Hi. Sorry for reposting. But it seems strange to me that such an ordinary
feature of Actions/MenuItem tooltip is not known by anybody.

Most of the application I see do have tooltips on menuItems: I can't believe
I should copy tooltips from action to MenuItem by hand...


I've searched in the docs to see if there is a flag that enables them w/o
finding anything.

sandro
*:-)

On Thu, Sep 02, 2010 at 10:13:37AM +0200, Alessandro Dentella wrote:
Hi again,


I use  UIManager() + group_action.add_actions() to create MenuItems and
ToolItems. I set tooltips as required by actiongroup.add_actions( 5^ field).

These tooltip show correctly for toolitems but they won't for menu
entries. Is it the desired behaviour? What can I do to have tooltips for
MenuItems as well? Note that

   ui_manager.get_action(action_name).props.tooltip

shows the tooltip correctly while *both* menyitem and toolitem don't (but
toolitem shows the tooltip correctly....):

   ui_manager.get_widget(menu_entry_name).props.tooltip_text   ### None
   ui_manager.get_widget(tool_entry_name).props.tooltip_text   ### None


.set_tooltip_text() works correctly in menu items, but it's terribly
inconvenient to set them one by one when I already set tooltips in the
actions, I guess I'm missing something!


any hints?

thanks

sandro
*:-)




--
Sandro Dentella  *:-)
http://sqlkit.argolinux.org        SQLkit home page - PyGTK/python/sqlalchemy
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
--
Sandro Dentella  *:-)
http://sqlkit.argolinux.org        SQLkit home page - PyGTK/python/sqlalchemy
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to