wxTextCtrl in wxToolbar, not showing in Mac

I’m having an issue maybe similar to one discussed here a few years ago (https://groups.google.com/forum/?fromgroups=#!searchin/wxpython-users/textctrl$20toolbar/wxpython-users/0u4H-ZSHPmY/9fsld4ujrogJ), except for me it works in WIndows and Linux but not Mac.

My issue is that a TextCtrl inside a Toolbar doesn’t show at all in Mac. The objects’ sizes all look OK but the TextCtrl is nowhere to be seen. My toolbar is attached to a frame, but that doesn’t seem to matter. The sizes and positions of the objects appear to be the same on all platforms.

My workaround has been to make a Mac-specific .xrc file that puts the TextCtrl inside a BoxSizer next to the Toolbar, but that means I have two .xrc files that need to stay synchronized. Using my Mac-specific xrc, the Toolbar seems to shrink so that the TextCtrl in the BoxSizer appears right next to the toolbar controls, but if I use the same xrc in Linux/Windows, the toolbar is full-sized and the TextCtrl appears far off to the side. So maybe the toolbar isn’t actually getting sized correctly in Mac?

I’ve attached a sample app that demonstrates the problem (not the workaround). The TextCtrl shows correctly in Ubuntu Precise with Wx 2.8.x and 2.9.4, and in Windows 7 with Wx 2.8.x and 2.9.4, but not in Mac OS X 10.8 with Wx 2.9.4 (Cocoa).

-John

toolbar-mac.zip (1.13 KB)

John Bender wrote:

I'm having an issue maybe similar to one discussed here a few years ago
(Redirecting to Google Groups),
except for me it works in WIndows and Linux but not Mac.

My issue is that a TextCtrl inside a Toolbar doesn't show at all in Mac.
The objects' sizes all look OK but the TextCtrl is nowhere to be seen.
My toolbar is attached to a frame, but that doesn't seem to matter. The
sizes and positions of the objects appear to be the same on all platforms.

My workaround has been to make a Mac-specific .xrc file that puts the
TextCtrl inside a BoxSizer next to the Toolbar, but that means I have
two .xrc files that need to stay synchronized. Using my Mac-specific
xrc, the Toolbar seems to shrink so that the TextCtrl in the BoxSizer
appears right next to the toolbar controls, but if I use the same xrc in
Linux/Windows, the toolbar is full-sized and the TextCtrl appears far
off to the side. So maybe the toolbar isn't actually getting sized
correctly in Mac?

I've attached a sample app that demonstrates the problem (not the
workaround). The TextCtrl shows correctly in Ubuntu Precise with Wx
2.8.x and 2.9.4, and in Windows 7 with Wx 2.8.x and 2.9.4, but not in
Mac OS X 10.8 with Wx 2.9.4 (Cocoa).

Make the toolbar be a direct child of the frame and not in any sizer, and don't use the dontattachtoframe tag. That will help ensure that the toolbar is the native toolbar on Mac and not a generic imitation. The frame has to manage the toolbar itself so it can treat it specially, not generically like any other child window.

···

--
Robin Dunn
Software Craftsman