Search code examples
wxpythonwxwidgets

wxPython: how to make two toolbars use one statusbar for tooltips?


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?


Solution

  • 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.