8000 Shorten and privatize qt's UiSubplotTool. · matplotlib/matplotlib@2518777 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2518777

Browse files
committed
Shorten and privatize qt's UiSubplotTool.
- Loop over the left and right groups to avoid some repetition. - Move towards making UiSubplotTool and its module private -- the public API is SubplotToolQt; just having an UI with no connected slots is not useful.
1 parent ac01f12 commit 2518777

File tree

4 files changed

+52
-55
lines changed

4 files changed

+52
-55
lines changed

doc/api/api_changes_3.3/deprecations.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ variables is deprecated. Additional fonts may be registered using
184184
~~~~~~~~~~~~~~~~~~~~~
185185
This module is deprecated.
186186

187+
``matplotlib.backends.qt_editor.formsubplottool``
188+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
189+
This module is deprecated. Use ``matplotlib.backends.backend_qt5.SubplotToolQt``
190+
instead.
191+
187192
AVConv animation writer deprecated
188193
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
189194
The ``AVConvBase``, ``AVConvWriter`` and ``AVConvFileWriter`` classes, and the

lib/matplotlib/backends/backend_qt5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
_Backend, FigureCanvasBase, FigureManagerBase, NavigationToolbar2,
1515
TimerBase, cursors, ToolContainerBase, StatusbarBase, MouseButton)
1616
import matplotlib.backends.qt_editor.figureoptions as figureoptions
17-
from matplotlib.backends.qt_editor.formsubplottool import UiSubplotTool
17+
from matplotlib.backends.qt_editor._formsubplottool import UiSubplotTool
1818
from . import qt_compat
1919
from .qt_compat import (
2020
QtCore, QtGui, QtWidgets, _isdeleted, is_pyqt5, __version__, QT_API)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from matplotlib.backends.qt_compat import QtWidgets
2+
3+
4+
class UiSubplotTool(QtWidgets.QDialog):
5+
6+
def __init__(self, *args, **kwargs):
7+
super().__init__(*args, **kwargs)
8+
self.setObjectName("SubplotTool")
9+
self._widgets = {}
10+
11+
main_layout = QtWidgets.QHBoxLayout()
12+
self.setLayout(main_layout)
13+
14+
for group, spinboxes, buttons in [
15+
("Borders",
16+
["top", "bottom", "left", "right"], ["Export values"]),
17+
("Spacings",
18+
["hspace", "wspace"], ["Tight layout", "Reset", "Close"]),
19+
]:
20+
layout = QtWidgets.QVBoxLayout()
21+
main_layout.addLayout(layout)
22+
box = QtWidgets.QGroupBox(group)
23+
layout.addWidget(box)
24+
inner = QtWidgets.QFormLayout(box)
25+
for name in spinboxes:
26+
self._widgets[name] = widget = QtWidgets.QDoubleSpinBox()
27+
widget.setMinimum(0)
28+
widget.setMaximum(1)
29+
widget.setDecimals(3)
30+
widget.setSingleStep(0.005)
31+
widget.setKeyboardTracking(False)
32+
inner.addRow(name, widget)
33+
layout.addStretch(1)
34+
for name in buttons:
35+
self._widgets[name] = widget = QtWidgets.QPushButton(name)
36+
# Don't trigger on <enter>, which is used to input values.
37+
widget.setAutoDefault(False)
38+
layout.addWidget(widget)
39+
40+
self._widgets["Close"].setFocus()
Lines changed: 6 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,8 @@
1-
from matplotlib.backends.qt_compat import QtWidgets
1+
from matplotlib import cbook
2+
from ._formsubplottool import UiSubplotTool
23

34

4-
class UiSubplotTool(QtWidgets.QDialog):
5-
6-
def __init__(self, *args, **kwargs):
7-
super().__init__(*args, **kwargs)
8-
self.setObjectName("SubplotTool")
9-
self._widgets = {}
10-
11-
layout = QtWidgets.QHBoxLayout()
12-
self.setLayout(layout)
13-
14-
left = QtWidgets.QVBoxLayout()
15-
layout.addLayout(left)
16-
right = QtWidgets.QVBoxLayout()
17-
layout.addLayout(right)
18-
19-
box = QtWidgets.QGroupBox("Borders")
20-
left.addWidget(box)
21-
inner = QtWidgets.QFormLayout(box)
22-
for side in ["top", "bottom", "left", "right"]:
23-
self._widgets[side] = widget = QtWidgets.QDoubleSpinBox()
24-
widget.setMinimum(0)
25-
widget.setMaximum(1)
26-
widget.setDecimals(3)
27-
widget.setSingleStep(.005)
28-
widget.setKeyboardTracking(False)
29-
inner.addRow(side, widget)
30-
left.addStretch(1)
31-
32-
box = QtWidgets.QGroupBox("Spacings")
33-
right.addWidget(box)
34-
inner = QtWidgets.QFormLayout(box)
35-
for side in ["hspace", "wspace"]:
36-
self._widgets[side] = widget = QtWidgets.QDoubleSpinBox()
37-
widget.setMinimum(0)
38-
widget.setMaximum(1)
39-
widget.setDecimals(3)
40-
widget.setSingleStep(.005)
41-
widget.setKeyboardTracking(False)
42-
inner.addRow(side, widget)
43-
right.addStretch(1)
44-
45-
widget = QtWidgets.QPushButton("Export values")
46-
self._widgets["Export values"] = widget
47-
# Don't trigger on <enter>, which is used to input values.
48-
widget.setAutoDefault(False)
49-
left.addWidget(widget)
50-
51-
for action in ["Tight layout", "Reset", "Close"]:
52-
self._widgets[action] = widget = QtWidgets.QPushButton(action)
53-
widget.setAutoDefault(False)
54-
right.addWidget(widget)
55-
56-
self._widgets["Close"].setFocus()
5+
cbook.warn_deprecated(
6+
"3.3", obj_type="module", name=__name__,
7+
alternative="matplotlib.backends.backend_qt5.SubplotToolQt")
8+
__all__ = ["UiSubplotTool"]

0 commit comments

Comments
 (0)
0