Tooltips

Hi,

   Two questions about tooltips and wx python. One, how do I add a tooltip to a menu item? Second, how do I get tooltips to show up for disabled gui elements. (The tip reminds the user what must be done to enable that element.)

    Thanks,
         Davison

···

--
-----------------------------------------------------------------------
- J. Davison de St. Germain dav@cs.utah.edu (801) 581-4078 -
- Chief Software Engineer http://www.cs.utah.edu/~dav -
- SCI Institute, SE C-SAFE University of Utah -
-----------------------------------------------------------------------

J. Davison de St. Germain wrote:

Hi,

  Two questions about tooltips and wx python. One, how do I add a tooltip to a menu item?

Native menus don't have tooltip support, but you could probably do it using the same mechanism that is used to show the tip text in the statusbar. Bind a handler to the EVT_MENU_HIGHLIGHT event and then based on the ID and the current cursor position you could show your own tip using the wx.TipWindow.

Second, how do I get tooltips to show up for disabled gui elements. (The tip reminds the user what must be done to enable that element.)

If the native platform doesn't show tooltips for disabled items already then you can't do it with native tooltips. But again you can do something yourself with wx.TipWindow. Be warned however that I've always found tip heavy applications to be real annoying and they usually end up in the trash real quick. I expect that I'm not the only one who feels that way.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Thank you for your response. :slight_smile:

   - Davison

Robin Dunn wrote:

···

J. Davison de St. Germain wrote:

Hi,

  Two questions about tooltips and wx python. One, how do I add a tooltip to a menu item?

Native menus don't have tooltip support, but you could probably do it using the same mechanism that is used to show the tip text in the statusbar. Bind a handler to the EVT_MENU_HIGHLIGHT event and then based on the ID and the current cursor position you could show your own tip using the wx.TipWindow.

Second, how do I get tooltips to show up for disabled gui elements. (The tip reminds the user what must be done to enable that element.)

If the native platform doesn't show tooltips for disabled items already then you can't do it with native tooltips. But again you can do something yourself with wx.TipWindow. Be warned however that I've always found tip heavy applications to be real annoying and they usually end up in the trash real quick. I expect that I'm not the only one who feels that way.

--
-----------------------------------------------------------------------
- J. Davison de St. Germain dav@cs.utah.edu (801) 581-4078 -
- Chief Software Engineer John Davison de St. Germain, U of U, Graduate Student -
- SCI Institute, SE C-SAFE University of Utah -
-----------------------------------------------------------------------

Hi
I'm trying to implement tool tips for menu items as suggested above.
However, in the event function for EVT_MENU_HIGHLIGHT I get a Segmentation
fault when TipWindow is instantiated.

Here's my code:

import wx
class MainApp(wx.App):
    def __init__(self):
        wx.App.__init__(self, redirect=False)
    def OnInit(self):
        self.frame = wx.Frame(None, -1, title='Simple:', pos=(100,100))
        menuBar = wx.MenuBar()
        menu=wx.Menu()
        item = menu.Append(wx.ID_HELP, text="&Help")
        self.Bind(wx.EVT_MENU_HIGHLIGHT, self.OnCtxHelp,item)
# self.tw=wx.TipWindow(self.frame,text="User Help") #
shown immediately!
        item = menu.Append(wx.ID_ABOUT, text="&About")
        self.Bind(wx.EVT_MENU, self.OnAbout, item)
        menuBar.Append(menu,"&Help")
        self.frame.SetMenuBar(menuBar)
        self.frame.Show(True)
        self.frame.SetSize((200,200))
        return True
    def OnCtxHelp(self,evt):
        print "OnCtxHelp"
# See this followed by
        self.tw=wx.TipWindow(self.frame,text="User Help") # Segmentation
Fault !
    def OnAbout(self,event):
        wx.MessageBox("ToolTips for menu items!", "About ToolTips:", wx.OK)
    def OnExitApp(self,event):
        self.frame.Close(True)
app = MainApp()
app.MainLoop()

I tried moving the TipWindow into OnInit, but that causes the ToolTip to
appear immediately!

Can anybody explain the Segfault? Does the above code work under Windows?
(I'm running wx-2.8-gtk2 under Linux)

Has anybody actually managed to implement platform tool tips for menu items?
If so I would be very great-full for some example code.
TIA

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/Tooltips-tp2370238p5717336.html
Sent from the wxPython-users mailing list archive at Nabble.com.