@@ -30,9 +30,10 @@ def fn_name(): return sys._getframe(1).f_code.co_name
30
30
from matplotlib ._pylab_helpers import Gcf
31
31
from matplotlib .backend_bases import RendererBase , GraphicsContextBase , \
32
32
FigureManagerBase , FigureCanvasBase , NavigationToolbar2 , cursors , TimerBase
33
- from matplotlib .backend_bases import ShowBase , ToolContainerBase , NavigationBase
34
- from matplotlib .backend_tools import SaveFigureBase , ConfigureSubplotsBase , \
35
- tools , toolbar_tools , SetCursorBase , RubberbandBase
33
+ from matplotlib .backend_bases import (ShowBase , ToolContainerBase ,
34
+ NavigationBase , StatusbarBase )
35
+ from matplotlib .backend_tools import (SaveFigureBase , ConfigureSubplotsBase ,
36
+ tools , toolbar_tools , SetCursorBase , RubberbandBase )
36
37
37
38
from matplotlib .cbook import is_string_like , is_writable_file_like
38
39
from matplotlib .colors import colorConverter
@@ -416,22 +417,30 @@ def __init__(self, canvas, num):
416
417
self .canvas .show ()
417
418
418
419
self .vbox .pack_start (self .canvas , True , True , 0 )
420
+ # calculate size for window
421
+ w = int (self .canvas .figure .bbox .width )
422
+ h = int (self .canvas .figure .bbox .height )
419
423
420
424
self .navigation = self ._get_navigation ()
421
425
self .toolbar = self ._get_toolbar ()
426
+ self .statusbar = None
427
+
428
+ def add_widget (child , expand , fill , padding ):
429
+ child .show ()
430
+ self .vbox .pack_end (child , False , False , 0 )
431
+ size_request = child .size_request ()
432
+ return size_request .height
433
+
422
434
if matplotlib .rcParams ['toolbar' ] == 'navigation' :
423
435
self .navigation .add_tools (tools )
424
436
self .toolbar .add_tools (toolbar_tools )
425
-
426
- # calculate size for window
427
- w = int (self .canvas .figure .bbox .width )
428
- h = int (self .canvas .figure .bbox .height )
437
+ self .statusbar = StatusbarGTK3 (self .navigation )
438
+ h += add_widget (self .statusbar , False , False , 0 )
439
+ h += add_widget (Gtk .HSeparator (), False , False , 0 )
429
440
430
441
if self .toolbar is not None :
431
442
self .toolbar .show ()
432
- self .vbox .pack_end (self .toolbar , False , False , 0 )
433
- size_request = self .toolbar .size_request ()
434
- h += size_request .height
443
+ h += add_widget (self .toolbar , False , False , 0 )
435
444
436
445
self .window .set_default_size (w , h )
437
446
@@ -767,23 +776,6 @@ def __init__(self, navigation):
767
776
self .pack_start (self ._toolbar , False , False , 0 )
768
777
self ._toolbar .show_all ()
769
778
self ._toolitems = {}
770
- self ._setup_message_area ()
771
-
772
- def _setup_message_area (self ):
773
- box = Gtk .Box ()
774
- box .set_property ("orientation" , Gtk .Orientation .HORIZONTAL )
775
- sep = Gtk .Separator ()
776
- sep .set_property ("orientation" , Gtk .Orientation .VERTICAL )
777
- box .pack_start (sep , False , True , 0 )
778
- self .message = Gtk .Label ()
779
- box .pack_end (self .message , False , False , 0 )
780
- self .pack_end (box , False , False , 5 )
781
- box .show_all ()
782
-
783
- sep = Gtk .Separator ()
784
- sep .set_property ("orientation" , Gtk .Orientation .HORIZONTAL )
785
- self .pack_end (sep , False , True , 0 )
786
- sep .show_all ()
787
779
788
780
def add_toolitem (self , name , group , position , image_file , description ,
789
781
toggle ):
@@ -811,9 +803,6 @@ def add_toolitem(self, name, group, position, image_file, description,
811
803
def _call_tool (self , btn , name ):
812
804
self .trigger_tool (name )
813
805
814
- def set_message (self , s ):
815
- self .message .set_label (s )
816
-
817
806
def toggle_toolitem (self , name , toggled ):
818
807
if name not in self ._toolitems :
819
808
return
@@ -824,9 +813,9 @@ def toggle_toolitem(self, name, toggled):
824
813
825
814
def remove_toolitem (self , name ):
826
815
if name not in self ._toolitems :
827
- self .set_message ('%s Not in toolbar' % name )
816
+ self .navigation . message_event ('%s Not in toolbar' % name , self )
828
817
return
829
- for toolitem , signal in self ._toolitems [name ]:
818
+ for toolitem , _signal in self ._toolitems [name ]:
830
819
self ._toolbar .remove (toolitem )
831
820
del self ._toolitems [name ]
832
821
@@ -837,6 +826,17 @@ def add_separator(self, pos=-1):
837
826
return toolitem
838
827
839
828
829
+ class StatusbarGTK3 (StatusbarBase , Gtk .Statusbar ):
830
+ def __init__ (self , * args , ** kwargs ):
831
+ StatusbarBase .__init__ (self , * args , ** kwargs )
832
+ Gtk .Statusbar .__init__ (self )
833
+ self ._context = self .get_context_id ('message' )
834
+
835
+ def set_message (self , s ):
836
+ self .pop (self ._context )
837
+ self .push (self ._context , s )
838
+
839
+
840
840
class SaveFigureGTK3 (SaveFigureBase ):
841
841
842
842
def get_filechooser (self ):
0 commit comments