toolbars on OS-X with wxPython2.8

Hi all,

Testing FloatCanvas on OS-X, I've noticed an issue with toolbars. I can't seem to place regular old buttons on a toolbar anymore.

I notices this notice under 2.7.1.1 Recent Changes:

"""
wxMac: I've turned on the compile option for using the native toolbar on the Mac now that it supports hosting of controls. If the toolbar is managed by the frame via either CreateToolBar() or SetToolBar() then the native toolbar will be used. Additional toolbars, or toolbars that are not children of the frame, are managed by sizers or what-not will still use the emulated toolbar because of platform restrictions in how/where the native toolbar can be used.
"""

In this case, I've got the toolbar manged by a sizer, so it should be using the old emulated toolbar, but it's not working right. I'll poke into this more, but just in case someone has a brilliant suggestion, here's a bit of the code:

     def BuildToolbar(self):
         tb = wx.ToolBar(self)
         self.ToolBar = tb
         tb.SetToolBitmapSize((24,24))

         self.PointerTool = tb.AddRadioTool(wx.ID_ANY,
                               bitmap=Resources.getPointerBitmap(),
                               shortHelp = "Pointer")
         self.Bind(wx.EVT_TOOL,
                   lambda evt : self.SetMode(Mode=self.GUIMouse),
                   self.PointerTool)

         self.ZoomInTool = tb.AddRadioTool(wx.ID_ANY,
                                     bitmap=Resources.getMagPlusBitmap(),
                                     shortHelp = "Zoom In")
         self.Bind(wx.EVT_TOOL,
                   lambda evt : self.SetMode(Mode=self.GUIZoomIn),
                   self.ZoomInTool)

         self.ZoomOutTool = tb.AddRadioTool(wx.ID_ANY,
                                    bitmap=Resources.getMagMinusBitmap(),
                                    shortHelp = "Zoom Out")
         self.Bind(wx.EVT_TOOL,
                  lambda evt : self.SetMode(Mode=self.GUIZoomOut),
                  self.ZoomOutTool)

         self.MoveTool = tb.AddRadioTool(wx.ID_ANY,
                                     bitmap=Resources.getHandBitmap(),
                                     shortHelp = "Move")
         self.Bind(wx.EVT_TOOL,
                   lambda evt : self.SetMode(Mode=self.GUIMove),
                   self.MoveTool)

         tb.AddSeparator()

         self.ZoomButton = wx.Button(tb, label="Zoom To Fit")
         tb.AddControl(self.ZoomButton)
         self.ZoomButton.Bind(wx.EVT_BUTTON, self.ZoomToFit)

         tb.Realize()

         return tb

The "ZoomButton" never gets rendered. Is there something I should be doing differently?

By the way, there are also some oddities in the toolbar used by matplotlib.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Christopher Barker wrote:

The "ZoomButton" never gets rendered. Is there something I should be doing differently?

No, I would expect that to work. Please enter a bug report about it.

···

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

Robin Dunn wrote:

The "ZoomButton" never gets rendered. Is there something I should be doing differently?

No, I would expect that to work. Please enter a bug report about it.

OK, after much delay, I've looked into this more. I now have a small demo that shows the problem. If you use a toolbar managed by the Frame, it works fine. If you use a toolbar created with wx.ToolBar(), and manage it yourself, you can't put a button on it.

The enclosed code has two toolbars, created with Exactly the same code. One managed by the frame, one not.

This works fine with 2.6.3 on OS-X and Windows, by the way. It fails with 2.8.1.1 on OS-X (with python2.5)

I'll file a big report,

-Chris

ToolBarSimple.py (7.14 KB)

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Christopher Barker wrote:

Robin Dunn wrote:

The "ZoomButton" never gets rendered. Is there something I should be doing differently?

No, I would expect that to work. Please enter a bug report about it.

OK, after much delay, I've looked into this more. I now have a small demo that shows the problem. If you use a toolbar managed by the Frame, it works fine. If you use a toolbar created with wx.ToolBar(), and manage it yourself, you can't put a button on it.

The enclosed code has two toolbars, created with Exactly the same code. One managed by the frame, one not.

Thanks, I'll take a quick look and see if anything jumps out at me. If not I'll turn it over to Stefan.

···

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

Robin Dunn wrote:

Christopher Barker wrote:

Robin Dunn wrote:

The "ZoomButton" never gets rendered. Is there something I should be doing differently?

No, I would expect that to work. Please enter a bug report about it.

OK, after much delay, I've looked into this more. I now have a small demo that shows the problem. If you use a toolbar managed by the Frame, it works fine. If you use a toolbar created with wx.ToolBar(), and manage it yourself, you can't put a button on it.

The enclosed code has two toolbars, created with Exactly the same code. One managed by the frame, one not.

Thanks, I'll take a quick look and see if anything jumps out at me. If not I'll turn it over to Stefan.

Still not sure what is causing it, but a workaround is to have a function that hides and shows the button, and call that with wx.CallAfter.

···

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

Robin Dunn wrote:

Still not sure what is causing it, but a workaround is to have a function that hides and shows the button, and call that with wx.CallAfter.

Thanks Robin, that will take care of it for me for now.

You really couldn't pay for support like you provide!

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception