FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Don't create a statusbar in Qt, wx backends. by anntzer · Pull Request #17092 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 6 additions & 0 deletions doc/api/api_changes_3.3/behaviour.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,9 @@ instead of ::

<a list of 3 Lists of Patches objects> # "bar", "barstacked"
<a list of 3 Lists of Patches objects> # "step", "stepfilled"

Qt and wx backends no longer create a status bar by default
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The coordinates information is now displayed in the toolbar, consistently with
Comment thread
tacaswell marked this conversation as resolved.
the other backends. This is intended to simplify embedding of Matplotlib in
larger GUIs, where Matplotlib may control the toolbar but not the status bar.
14 changes: 5 additions & 9 deletions lib/matplotlib/backend_bases.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2881,22 +2881,18 @@ def mouse_move(self, event):
except (ValueError, OverflowError):
pass
else:
s = s.rstrip()
artists = [a for a in event.inaxes._mouseover_set
if a.contains(event)[0] and a.get_visible()]

if artists:
a = cbook._topmost_artist(artists)
if a is not event.inaxes.patch:
data = a.get_cursor_data(event)
if data is not None:
data_str = a.format_cursor_data(data)
if data_str is not None:
s = s + ' ' + data_str

if len(self.mode):
self.set_message('%s, %s' % (self.mode, s))
else:
self.set_message(s)
data_str = a.format_cursor_data(data).rstrip()
if data_str:
s = s + '\n' + data_str
self.set_message(s)
else:
self.set_message(self.mode)

Expand Down
16 changes: 7 additions & 9 deletions lib/matplotlib/backends/backend_qt5.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -550,23 +550,21 @@ def __init__(self, canvas, num):
if self.toolbar:
backend_tools.add_tools_to_container(self.toolbar)
self.statusbar = StatusbarQt(self.window, self.toolmanager)
sbs_height = self.statusbar.sizeHint().height()
else:
sbs_height = 0

timhoffm Apr 11, 2020 •
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Typo? Is this the same as sb_height? If so, please also make sure that the variable is set via all condition code paths. If not, can we make this variables more distinctive?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

actually they should all be sbs_height, fixed


if self.toolbar is not None:
self.window.addToolBar(self.toolbar)
if not self.toolmanager:
# add text label to status bar
statusbar_label = QtWidgets.QLabel()
self.window.statusBar().addWidget(statusbar_label)
self.toolbar.message.connect(statusbar_label.setText)
tbs_height = self.toolbar.sizeHint().height()
else:
tbs_height = 0

# resize the main window so it will display the canvas with the
# requested size:
cs = canvas.sizeHint()
sbs = self.window.statusBar().sizeHint()
height = cs.height() + tbs_height + sbs.height()
cs_height = cs.height()
height = cs_height + tbs_height + sbs_height
self.window.resize(cs.width(), height)

self.window.setCentralWidget(self.canvas)
Expand Down Expand Up @@ -599,7 +597,7 @@ def _get_toolbar(self, canvas, parent):
# must be inited after the window, drawingArea and figure
# attrs are set
if matplotlib.rcParams['toolbar'] == 'toolbar2':
toolbar = NavigationToolbar2QT(canvas, parent, False)
toolbar = NavigationToolbar2QT(canvas, parent, True)
elif matplotlib.rcParams['toolbar'] == 'toolmanager':
toolbar = ToolbarQt(self.toolmanager, self.window)
else:
Expand Down Expand Up @@ -679,7 +677,7 @@ def __init__(self, canvas, parent, coordinates=True):
if self.coordinates:
self.locLabel = QtWidgets.QLabel("", self)
self.locLabel.setAlignment(
QtCore.Qt.AlignRight | QtCore.Qt.AlignTop)
QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.locLabel.setSizePolicy(
QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Ignored))
Expand Down
16 changes: 8 additions & 8 deletions lib/matplotlib/backends/backend_wx.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -928,13 +928,11 @@ def __init__(self, num, fig):

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

statusbar = (StatusbarWx(self, self.toolmanager)
if self.toolmanager else StatusBarWx(self))
self.SetStatusBar(statusbar)
self.toolbar = self._get_toolbar()

if self.toolmanager:
backend_tools.add_tools_to_manager(self.toolmanager)
if self.figmgr.toolmanager:
self.SetStatusBar(StatusbarWx(self, self.figmgr.toolmanager))
backend_tools.add_tools_to_manager(self.figmgr.toolmanager)
if self.toolbar:
backend_tools.add_tools_to_container(self.toolbar)

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

self.AddStretchableSpace()
self._label_text = wx.StaticText(self)
self.AddControl(self._label_text)

self.Realize()

NavigationToolbar2.__init__(self, canvas)
Expand Down Expand Up @@ -1300,9 +1302,7 @@ def statbar(self):
return self.GetTopLevelParent().GetStatusBar()

def set_message(self, s):
status_bar = self.GetTopLevelParent().GetStatusBar()
if status_bar is not None:
status_bar.set_function(s)
self._label_text.SetLabel(s)

def set_history_buttons(self):
can_backward = self._nav_stack._pos > 0
Expand Down

Back | FazBrowse Home | New Git URL