Search code examples
wxpython

How can I cast a wxAuiToolBar from wxControl


I have what I believe to be a wxAuiToolBar pointer (I'm calling it tb):

wx.__version__    --> '3.0.2.0'
tb                --> <wx._core.Control; proxy of <Swig Object of type 'wxControl *' at 0x474e600> >

tb.GetClassName() --> u'wxAuiToolBar

tb.__class__ --> <class 'wx._core.Control'>

wxPyTypeCast is no longer in wxPython but I'd like to get to the tool buttons.

I got the pointer from the GetChildren() method of the parent frame.

Since python things it's just a control, I can access the toolbar methods.

What am I doing wrong?


Solution

  • turns out that if I do:

    import wx.aui

    Before I get a pointer to the toolbar, I'll get a pointer of the correct type:

    <wx.aui.AuiToolBar; proxy of <Swig Object of type 'wxAuiToolBar *' at 0x53c0200> >

    If I import after the first access, the pointer will continue to just be of type wxControl. Not a big deal if you know that's how it behaves.