Reputation: 386372
I have an interface that has two toolbars, one attached to the frame and one embedded in a notebook tab. The one in the frame dutifully shows longHelp strings in the statusbar, the one in the notebook tab does not. How do I tell the one on the notebook tab where to display its help, or do I have to manage enter and leave bindings myself?
Upvotes: 2
Views: 1053
Reputation: 56
Although this post is fairly old, I just stumbled upon this same problem myself. Using wxPython Phoenix 4.0.0a4, the solution I found was to bind a function to the EVT_TOOL_ENTER event using the toolbar's id.
your_frame.Bind(wx.EVT_TOOL_ENTER, your_function, id=toolbar_id)
Then in your_function you can get the tool from the toolbar, the help text from the tool and write that into the status bar.
def your_function(e):
tool_id = e.GetSelection()
if tool_id != -1:
# if the mouse is over a toolbar item
event_object = e.GetEventObject()
tool = event_object.FindById(tool_id)
text = tool.GetLongHelp()
else:
# if the mouse is in the toolbar area, but not on an item
text = some_default_text
your_frame.GetStatusBar().SetStatusText(text)
A short description of the EVT_TOOL_ENTER can be found in the wxPython docs.
Upvotes: 2
Reputation: 3581
You have in wxWidgets:
void wxToolBarBase::OnMouseEnter(int id)
{
...
wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
if ( frame )
{
...
frame->DoGiveHelp(help, id != wxID_ANY);
}
...
}
In C++ program you can override this function (simply changing GetParent() to GetTopLevelParent() should work). In Python you can only, as you wrote, bind enter/leave events and call DoGiveHelp() from handlers.
Upvotes: 0
Reputation: 88865
from wxPython docs """ longHelpString This string is shown in the statusbar (if any) of the parent frame when the mouse pointer is inside the tool """
so toolbar in notebook doesn't get any statusbar to display long help, so either thru src we should invertigate how it inquires abt status bar and supply a ref to main frame status bar
else i think better way is to just override wxToolBar::OnMouseEnter and display help directly on status bar
Upvotes: 0