Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ef8a6ae

Browse filesBrowse files
authored
Merge pull request #17092 from anntzer/nostatbar
Don't create a statusbar in Qt, wx backends.
2 parents 95ada39 + 21eb1e9 commit ef8a6ae
Copy full SHA for ef8a6ae

File tree

Expand file treeCollapse file tree

4 files changed

+26
-26
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+26
-26
lines changed

‎doc/api/api_changes_3.3/behaviour.rst

Copy file name to clipboardExpand all lines: doc/api/api_changes_3.3/behaviour.rst
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,9 @@ instead of ::
274274

275275
<a list of 3 Lists of Patches objects> # "bar", "barstacked"
276276
<a list of 3 Lists of Patches objects> # "step", "stepfilled"
277+
278+
Qt and wx backends no longer create a status bar by default
279+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
280+
The coordinates information is now displayed in the toolbar, consistently with
281+
the other backends. This is intended to simplify embedding of Matplotlib in
282+
larger GUIs, where Matplotlib may control the toolbar but not the status bar.

‎lib/matplotlib/backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
+5-9Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2881,22 +2881,18 @@ def mouse_move(self, event):
28812881
except (ValueError, OverflowError):
28822882
pass
28832883
else:
2884+
s = s.rstrip()
28842885
artists = [a for a in event.inaxes._mouseover_set
28852886
if a.contains(event)[0] and a.get_visible()]
2886-
28872887
if artists:
28882888
a = cbook._topmost_artist(artists)
28892889
if a is not event.inaxes.patch:
28902890
data = a.get_cursor_data(event)
28912891
if data is not None:
2892-
data_str = a.format_cursor_data(data)
2893-
if data_str is not None:
2894-
s = s + ' ' + data_str
2895-
2896-
if len(self.mode):
2897-
self.set_message('%s, %s' % (self.mode, s))
2898-
else:
2899-
self.set_message(s)
2892+
data_str = a.format_cursor_data(data).rstrip()
2893+
if data_str:
2894+
s = s + '\n' + data_str
2895+
self.set_message(s)
29002896
else:
29012897
self.set_message(self.mode)
29022898

‎lib/matplotlib/backends/backend_qt5.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt5.py
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -550,23 +550,21 @@ def __init__(self, canvas, num):
550550
if self.toolbar:
551551
backend_tools.add_tools_to_container(self.toolbar)
552552
self.statusbar = StatusbarQt(self.window, self.toolmanager)
553+
sbs_height = self.statusbar.sizeHint().height()
554+
else:
555+
sbs_height = 0
553556

554557
if self.toolbar is not None:
555558
self.window.addToolBar(self.toolbar)
556-
if not self.toolmanager:
557-
# add text label to status bar
558-
statusbar_label = QtWidgets.QLabel()
559-
self.window.statusBar().addWidget(statusbar_label)
560-
self.toolbar.message.connect(statusbar_label.setText)
561559
tbs_height = self.toolbar.sizeHint().height()
562560
else:
563561
tbs_height = 0
564562

565563
# resize the main window so it will display the canvas with the
566564
# requested size:
567565
cs = canvas.sizeHint()
568-
sbs = self.window.statusBar().sizeHint()
569-
height = cs.height() + tbs_height + sbs.height()
566+
cs_height = cs.height()
567+
height = cs_height + tbs_height + sbs_height
570568
self.window.resize(cs.width(), height)
571569

572570
self.window.setCentralWidget(self.canvas)
@@ -599,7 +597,7 @@ def _get_toolbar(self, canvas, parent):
599597
# must be inited after the window, drawingArea and figure
600598
# attrs are set
601599
if matplotlib.rcParams['toolbar'] == 'toolbar2':
602-
toolbar = NavigationToolbar2QT(canvas, parent, False)
600+
toolbar = NavigationToolbar2QT(canvas, parent, True)
603601
elif matplotlib.rcParams['toolbar'] == 'toolmanager':
604602
toolbar = ToolbarQt(self.toolmanager, self.window)
605603
else:
@@ -679,7 +677,7 @@ def __init__(self, canvas, parent, coordinates=True):
679677
if self.coordinates:
680678
self.locLabel = QtWidgets.QLabel("", self)
681679
self.locLabel.setAlignment(
682-
QtCore.Qt.AlignRight | QtCore.Qt.AlignTop)
680+
QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
683681
self.locLabel.setSizePolicy(
684682
QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
685683
QtWidgets.QSizePolicy.Ignored))

‎lib/matplotlib/backends/backend_wx.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_wx.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -928,13 +928,11 @@ def __init__(self, num, fig):
928928

929929
self.figmgr = FigureManagerWx(self.canvas, num, self)
930930

931-
statusbar = (StatusbarWx(self, self.toolmanager)
932-
if self.toolmanager else StatusBarWx(self))
933-
self.SetStatusBar(statusbar)
934931
self.toolbar = self._get_toolbar()
935932

936-
if self.toolmanager:
937-
backend_tools.add_tools_to_manager(self.toolmanager)
933+
if self.figmgr.toolmanager:
934+
self.SetStatusBar(StatusbarWx(self, self.figmgr.toolmanager))
935+
backend_tools.add_tools_to_manager(self.figmgr.toolmanager)
938936
if self.toolbar:
939937
backend_tools.add_tools_to_container(self.toolbar)
940938

@@ -1122,6 +1120,10 @@ def __init__(self, canvas):
11221120
self.Bind(wx.EVT_TOOL, getattr(self, callback),
11231121
id=self.wx_ids[text])
11241122

1123+
self.AddStretchableSpace()
1124+
self._label_text = wx.StaticText(self)
1125+
self.AddControl(self._label_text)
1126+
11251127
self.Realize()
11261128

11271129
NavigationToolbar2.__init__(self, canvas)
@@ -1300,9 +1302,7 @@ def statbar(self):
13001302
return self.GetTopLevelParent().GetStatusBar()
13011303

13021304
def set_message(self, s):
1303-
status_bar = self.GetTopLevelParent().GetStatusBar()
1304-
if status_bar is not None:
1305-
status_bar.set_function(s)
1305+
self._label_text.SetLabel(s)
13061306

13071307
def set_history_buttons(self):
13081308
can_backward = self._nav_stack._pos > 0

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.