@@ -230,7 +230,7 @@ def __init__(self, parent, points, bins=100, **kwargs):
230230 self .gate_helper = GatingHelper (self .subplot , self )
231231
232232 self .navtoolbar = NavigationToolbar (self .canvas )
233- self .navtoolbar .Realize ()
233+ # self.navtoolbar.Realize()
234234
235235 self .x_label = ''
236236 self .log_y = False
@@ -366,7 +366,9 @@ def __init__(self, parent, size=(600,600), **kwargs):
366366 figpanel = HistogramPanel (self , points )
367367 configpanel = DataSourcePanel (self , figpanel )
368368 figpanel .set_configpanel (configpanel )
369+
369370 self .SetToolBar (figpanel .get_toolbar ())
371+
370372 sizer = wx .BoxSizer (wx .VERTICAL )
371373 sizer .Add (figpanel , 1 , wx .EXPAND )
372374 sizer .Add (configpanel , 0 , wx .EXPAND | wx .ALL , 5 )
@@ -378,6 +380,42 @@ def __init__(self, parent, size=(600,600), **kwargs):
378380 self .save_settings = configpanel .save_settings
379381 self .load_settings = configpanel .load_settings
380382 self .fig = figpanel
383+
384+ # Hack: See http://stackoverflow.com/questions/6124419/matplotlib-navtoolbar-doesnt-realize-in-wx-2-9-mac-os-x
385+ def SetToolBar (self , toolbar ):
386+ from matplotlib .backends .backend_wx import _load_bitmap
387+ toolbar .Hide ()
388+ tb = self .CreateToolBar ((wx .TB_HORIZONTAL | wx .TB_TEXT ))
389+
390+ _NTB2_HOME = wx .NewId ()
391+ _NTB2_BACK = wx .NewId ()
392+ _NTB2_FORWARD = wx .NewId ()
393+ _NTB2_PAN = wx .NewId ()
394+ _NTB2_ZOOM = wx .NewId ()
395+ _NTB2_SAVE = wx .NewId ()
396+ _NTB2_SUBPLOT = wx .NewId ()
397+ tb .AddSimpleTool (_NTB2_HOME , _load_bitmap ('home.png' ), 'Home' , 'Reset original view' )
398+ tb .AddSimpleTool (_NTB2_BACK , _load_bitmap ('back.png' ), 'Back' , 'Back navigation view' )
399+ tb .AddSimpleTool (_NTB2_FORWARD , _load_bitmap ('forward.png' ), 'Forward' , 'Forward navigation view' )
400+
401+ tb .AddCheckTool (_NTB2_PAN , _load_bitmap ('move.png' ), shortHelp = 'Pan' , longHelp = 'Pan with left, zoom with right' )
402+ tb .AddCheckTool (_NTB2_ZOOM , _load_bitmap ('zoom_to_rect.png' ), shortHelp = 'Zoom' , longHelp = 'Zoom to rectangle' )
403+
404+ tb .AddSeparator ()
405+ tb .AddSimpleTool (_NTB2_SUBPLOT , _load_bitmap ('subplots.png' ), 'Configure subplots' , 'Configure subplot parameters' )
406+ tb .AddSimpleTool (_NTB2_SAVE , _load_bitmap ('filesave.png' ), 'Save' , 'Save plot contents to file' )
407+
408+ self .Bind (wx .EVT_TOOL , toolbar .home , id = _NTB2_HOME )
409+ self .Bind (wx .EVT_TOOL , toolbar .forward , id = _NTB2_FORWARD )
410+ self .Bind (wx .EVT_TOOL , toolbar .back , id = _NTB2_BACK )
411+ self .Bind (wx .EVT_TOOL , toolbar .zoom , id = _NTB2_ZOOM )
412+ self .Bind (wx .EVT_TOOL , toolbar .pan , id = _NTB2_PAN )
413+ self .Bind (wx .EVT_TOOL , toolbar .configure_subplots , id = _NTB2_SUBPLOT )
414+ self .Bind (wx .EVT_TOOL , toolbar .save_figure , id = _NTB2_SAVE )
415+
416+ tb .Realize ()
417+ # Hack end
418+
381419
382420
383421if __name__ == "__main__" :
0 commit comments