Re: [wxPython] type(event.GetEventObject()) is string???
> This is OK. I Click on ToolButton now:
> _1286590_wxObject_p: <type 'string'>
> Is this OK too?
> I want this:
> but event.GetEventObject is string, not pointer.
> Can you help me?
There are a couple problems. Since the C++ version of GetEventObject returns
a wxObject*, which wxPython doesn't know much about, it just returns the
"SWIGified pointer" which is a string. Even if wxPython knew about wxObject
it wouldn't help much as it can't tell if it's really a wxWindow, a wxButton,
or a wxToolBarTool. For this purpose I have included a helper function
called wxPyTypeCast (**) which behaves similarly to a typecast in C++, it
allows you to take the swigified pointer and convert it to a specific shadow
class object. So in your case:
eo = event.GetEventObject()
tbt = wxPyTypeCast(eo, "wxToolBarTool")
It looks like you are expecting to get a wxButton and be able to set it's
label. Unfortunately the toolbar tools are not wxButtons so you are out of
There are several "public members" of the wxToolBarTool that you do have
access to, so you might be able to do something like this:
tbt.m_bitmap1 = SomeOtherBitmap
tbt.m_shortHelpString = "test text" # this is the tooltip
You can also change some of these things from the toolbar itself: