Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a9ca0f5

Browse files
authored
Merge pull request #14733 from anntzer/wxstatbar
Deprecate FigureFrameWx.statusbar & NavigationToolbar2Wx.statbar.
2 parents 60bc475 + a43b90d commit a9ca0f5

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Deprecations
2+
````````````
3+
4+
``FigureFrameWx.statusbar`` and ``NavigationToolbar2Wx.statbar`` are deprecated.
5+
The status bar can be retrieved by calling standard wx methods
6+
(``frame.GetStatusBar()`` and ``toolbar.GetTopLevelParent().GetStatusBar()``).

lib/matplotlib/backends/backend_wx.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,12 +1029,10 @@ def __init__(self, num, fig):
10291029
# of the frame - so appearance is closer to GTK version
10301030

10311031
self.toolmanager = self._get_toolmanager()
1032-
if self.toolmanager:
1033-
self.statusbar = StatusbarWx(self, self.toolmanager)
1034-
else:
1035-
self.statusbar = StatusBarWx(self)
1036-
self.SetStatusBar(self.statusbar)
1037-
self.toolbar = self._get_toolbar(self.statusbar)
1032+
statusbar = (StatusbarWx(self, self.toolmanager)
1033+
if self.toolmanager else StatusBarWx(self))
1034+
self.SetStatusBar(statusbar)
1035+
self.toolbar = self._get_toolbar()
10381036

10391037
if self.toolmanager:
10401038
backend_tools.add_tools_to_manager(self.toolmanager)
@@ -1060,10 +1058,14 @@ def __init__(self, num, fig):
10601058

10611059
self.Bind(wx.EVT_CLOSE, self._onClose)
10621060

1063-
def _get_toolbar(self, statbar):
1061+
@cbook.deprecated("3.2", alternative="self.GetStatusBar()")
1062+
@property
1063+
def statusbar(self):
1064+
return self.GetStatusBar()
1065+
1066+
def _get_toolbar(self):
10641067
if rcParams['toolbar'] == 'toolbar2':
10651068
toolbar = NavigationToolbar2Wx(self.canvas)
1066-
toolbar.set_status_bar(statbar)
10671069
elif matplotlib.rcParams['toolbar'] == 'toolmanager':
10681070
toolbar = ToolbarWx(self.toolmanager, self)
10691071
else:
@@ -1305,7 +1307,6 @@ def __init__(self, canvas):
13051307
NavigationToolbar2.__init__(self, canvas)
13061308
self.canvas = canvas
13071309
self._idle = True
1308-
self.statbar = None
13091310
self.prevZoomRect = None
13101311
# for now, use alternate zoom-rectangle drawing on all
13111312
# Macs. N.B. In future versions of wx it may be possible to
@@ -1485,12 +1486,20 @@ def draw_rubberband(self, event, x0, y0, x1, y1):
14851486
dc.SetBrush(wx.Brush(color))
14861487
dc.DrawRectangle(rect)
14871488

1489+
@cbook.deprecated("3.2")
14881490
def set_status_bar(self, statbar):
1489-
self.statbar = statbar
1491+
self.GetTopLevelParent().SetStatusBar(statbar)
1492+
1493+
@cbook.deprecated("3.2",
1494+
alternative="self.GetTopLevelParent().GetStatusBar()")
1495+
@property
1496+
def statbar(self):
1497+
return self.GetTopLevelParent().GetStatusBar()
14901498

14911499
def set_message(self, s):
1492-
if self.statbar is not None:
1493-
self.statbar.set_function(s)
1500+
status_bar = self.GetTopLevelParent().GetStatusBar()
1501+
if status_bar is not None:
1502+
status_bar.set_function(s)
14941503

14951504
def set_history_buttons(self):
14961505
can_backward = self._nav_stack._pos > 0

0 commit comments

Comments
 (0)