Toolbar issues with wxFrame and wxSizer on OS/X

Rajas Sambhare wrote:

Hi:

The code below produces a toolbar and a Ok button underneath it on Win32. On OS/X however there is a blank space for the toolbar followed by an Ok button.

Am I doing something wrong in the way I've set the layout using the sizer? If not are there a workaround for this kind of behaviour?

Two problems. First: the default size of the toolbar is set very small on the Mac and so since you didn't tell the sizer to resize it it stayed too small to see. Second problem: You did not call SetSizer and so when the frame's resize event happened it did not call Layout again.

     def __init__(self, parent = None, id = -1,
                  pos = wx.wxDefaultPosition, size = wx.wxDefaultSize,
                  title = "Toolbar test"):
         """Create a frame"""
         wx.wxFrame.__init__(self, parent, id, title, pos, size)
         sizer = wx.wxBoxSizer(wx.wxVERTICAL)

         tb = wx.wxToolBar(self, -1,
                           wx.wxDefaultPosition, wx.wxDefaultSize,
                           wx.wxTB_HORIZONTAL | wx.wxNO_BORDER | wx.wxTB_TEXT)

         tb.AddSimpleTool(10, GetPlusBitmap(), "Zoom In", "Zooooom In")
         tb.AddTool(11, GetMinusBitmap(), isToggle=1, shortHelpString="Zoom Out")
         tb.Realize()
         sizer.Add(tb, flag=wx.wxALIGN_TOP|wx.wxEXPAND, border = 10)

         button1 = wx.wxButton(self, wx.wxID_OK, "Ok")
         sizer.Add(button1, flag=wx.wxALIGN_BOTTOM, border = 10)

         self.SetSizer(sizer)

ยทยทยท

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!