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 1889c04

Browse filesBrowse files
committed
STY : pep8 work on qt* files
1 parent 3779fab commit 1889c04
Copy full SHA for 1889c04

File tree

Expand file treeCollapse file tree

7 files changed

+52
-49
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+52
-49
lines changed

‎lib/matplotlib/backends/backend_qt4.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt4.py
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,25 @@
3232
from .qt_compat import QtCore, QtWidgets, _getSaveFileName, __version__
3333
from matplotlib.backends.qt_editor.formsubplottool import UiSubplotTool
3434

35-
from .backend_qt5 import (backend_version, SPECIAL_KEYS, SUPER, ALT, CTRL,
35+
from .backend_qt5 import (backend_version, SPECIAL_KEYS, SUPER, ALT, CTRL,
3636
SHIFT, MODIFIER_KEYS, fn_name, cursord,
37-
draw_if_interactive, _create_qApp, show, TimerQT,
37+
draw_if_interactive, _create_qApp, show, TimerQT,
3838
MainWindow, FigureManagerQT, NavigationToolbar2QT,
3939
SubplotToolQt, error_msg_qt, exception_handler)
4040

4141
from .backend_qt5 import FigureCanvasQT as FigureCanvasQT5
4242

4343
DEBUG = False
4444

45+
4546
def new_figure_manager(num, *args, **kwargs):
4647
"""
4748
Create a new figure manager instance
4849
"""
4950
thisFig = Figure(*args, **kwargs)
5051
return new_figure_manager_given_figure(num, thisFig)
5152

53+
5254
def new_figure_manager_given_figure(num, figure):
5355
"""
5456
Create a new figure manager instance for the given figure.
@@ -57,6 +59,7 @@ def new_figure_manager_given_figure(num, figure):
5759
manager = FigureManagerQT(canvas, num)
5860
return manager
5961

62+
6063
class FigureCanvasQT(FigureCanvasQT5):
6164

6265
def __init__(self, figure):
@@ -71,7 +74,7 @@ def __init__(self, figure):
7174
self.setMouseTracking(True)
7275
self._idle = True
7376
# hide until we can test and fix
74-
#self.startTimer(backend_IdleEvent.milliseconds)
77+
# self.startTimer(backend_IdleEvent.milliseconds)
7578
w, h = self.get_width_height()
7679
self.resize(w, h)
7780

‎lib/matplotlib/backends/backend_qt4agg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt4agg.py
+3-12Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,16 @@
3636
_decref.restype = None
3737

3838

39-
def new_figure_manager(num, *args, **kwargs):
40-
"""
41-
Create a new figure manager instance
42-
"""
43-
if DEBUG:
44-
print('backend_qt4agg.new_figure_manager')
45-
FigureClass = kwargs.pop('FigureClass', Figure)
46-
thisFig = FigureClass(*args, **kwargs)
47-
return new_figure_manager_given_figure(num, thisFig)
48-
4939
def new_figure_manager_given_figure(num, figure):
5040
"""
5141
Create a new figure manager instance for the given figure.
5242
"""
5343
canvas = FigureCanvasQTAgg(figure)
5444
return FigureManagerQT(canvas, num)
5545

56-
class FigureCanvasQTAgg(FigureCanvasQTAggBase, FigureCanvasQT, FigureCanvasAgg):
46+
47+
class FigureCanvasQTAgg(FigureCanvasQTAggBase,
48+
FigureCanvasQT, FigureCanvasAgg):
5749
"""
5850
The canvas the figure renders into. Calls the draw and print fig
5951
methods, creates the renderers, etc...
@@ -89,6 +81,5 @@ def __init__(self, figure):
8981
self._priv_update = self.update
9082

9183

92-
9384
FigureCanvas = FigureCanvasQTAgg
9485
FigureManager = FigureManagerQT

‎lib/matplotlib/backends/backend_qt5.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt5.py
+11-5Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ def draw_if_interactive():
116116
if figManager is not None:
117117
figManager.canvas.draw_idle()
118118

119+
# make place holder
120+
qApp = None
121+
119122

120123
def _create_qApp():
121124
"""
@@ -227,13 +230,15 @@ def __init__(self, figure):
227230
print('FigureCanvasQt qt5: ', figure)
228231
_create_qApp()
229232

230-
# NB: Using super for this call to avoid a TypeError: __init__() takes exactly 2 arguments (1 given) on QWidget PyQt5
233+
# NB: Using super for this call to avoid a TypeError:
234+
# __init__() takes exactly 2 arguments (1 given) on QWidget
235+
# PyQt5
231236
super(FigureCanvasQT, self).__init__(figure=figure)
232237
self.figure = figure
233238
self.setMouseTracking(True)
234239
self._idle = True
235240
# hide until we can test and fix
236-
#self.startTimer(backend_IdleEvent.milliseconds)
241+
# self.startTimer(backend_IdleEvent.milliseconds)
237242
w, h = self.get_width_height()
238243
self.resize(w, h)
239244

@@ -274,7 +279,7 @@ def mouseMoveEvent(self, event):
274279
# flipy so y=0 is bottom of canvas
275280
y = self.figure.bbox.height - event.y()
276281
FigureCanvasBase.motion_notify_event(self, x, y)
277-
#if DEBUG: print('mouse move')
282+
# if DEBUG: print('mouse move')
278283

279284
def mouseReleaseEvent(self, event):
280285
x = event.x()
@@ -647,7 +652,7 @@ def edit_parameters(self):
647652
figureoptions.figure_edit(axes, self)
648653

649654
def _update_buttons_checked(self):
650-
#sync button checkstates to match active mode
655+
# sync button checkstates to match active mode
651656
self._actions['pan'].setChecked(self._active == 'PAN')
652657
self._actions['zoom'].setChecked(self._active == 'ZOOM')
653658

@@ -824,7 +829,8 @@ def error_msg_qt(msg, parent=None):
824829
if not is_string_like(msg):
825830
msg = ','.join(map(str, msg))
826831

827-
QtWidgets.QMessageBox.warning(None, "Matplotlib", msg, QtGui.QMessageBox.Ok)
832+
QtWidgets.QMessageBox.warning(None, "Matplotlib",
833+
msg, QtGui.QMessageBox.Ok)
828834

829835

830836
def exception_handler(type, value, tb):

‎lib/matplotlib/backends/backend_qt5agg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt5agg.py
+13-8Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
_decref.argtypes = [ctypes.py_object]
3737
_decref.restype = None
3838

39+
3940
def new_figure_manager(num, *args, **kwargs):
4041
"""
4142
Create a new figure manager instance
@@ -46,13 +47,15 @@ def new_figure_manager(num, *args, **kwargs):
4647
thisFig = FigureClass(*args, **kwargs)
4748
return new_figure_manager_given_figure(num, thisFig)
4849

50+
4951
def new_figure_manager_given_figure(num, figure):
5052
"""
5153
Create a new figure manager instance for the given figure.
5254
"""
5355
canvas = FigureCanvasQTAgg(figure)
5456
return FigureManagerQT(canvas, num)
5557

58+
5659
class FigureCanvasQTAggBase(object):
5760
"""
5861
The canvas the figure renders into. Calls the draw and print fig
@@ -62,7 +65,7 @@ class FigureCanvasQTAggBase(object):
6265
6366
figure - A Figure instance
6467
"""
65-
68+
6669
def drawRectangle(self, rect):
6770
self._drawRect = rect
6871
self.repaint()
@@ -74,7 +77,7 @@ def paintEvent(self, e):
7477
shown onscreen.
7578
"""
7679

77-
#FigureCanvasQT.paintEvent(self, e)
80+
# FigureCanvasQT.paintEvent(self, e)
7881
if DEBUG:
7982
print('FigureCanvasQtAgg.paintEvent: ', self,
8083
self.get_width_height())
@@ -157,12 +160,14 @@ def blit(self, bbox=None):
157160
def print_figure(self, *args, **kwargs):
158161
FigureCanvasAgg.print_figure(self, *args, **kwargs)
159162
self.draw()
160-
161-
class FigureCanvasQTAgg(FigureCanvasQTAggBase, FigureCanvasQT, FigureCanvasAgg):
163+
164+
165+
class FigureCanvasQTAgg(FigureCanvasQTAggBase,
166+
FigureCanvasQT, FigureCanvasAgg):
162167
"""
163168
The canvas the figure renders into. Calls the draw and print fig
164-
methods, creates the renderers, etc.
165-
169+
methods, creates the renderers, etc.
170+
166171
Modified to import from Qt5 backend for new-style mouse events.
167172
168173
Public attribute
@@ -194,7 +199,8 @@ def __init__(self, figure):
194199
self._priv_update = self.repaint
195200
else:
196201
self._priv_update = self.update
197-
202+
203+
198204
class NavigationToolbar2QTAgg(NavigationToolbar2QT):
199205
def __init__(*args, **kwargs):
200206
warnings.warn('This class has been deprecated in 1.4 ' +
@@ -205,6 +211,5 @@ def __init__(*args, **kwargs):
205211
NavigationToolbar2QT.__init__(*args, **kwargs)
206212

207213

208-
209214
FigureCanvas = FigureCanvasQTAgg
210215
FigureManager = FigureManagerQT

‎lib/matplotlib/backends/qt_compat.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/qt_compat.py
+16-18Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
except KeyError:
2828
raise RuntimeError(
2929
'Unrecognized environment variable %r, valid values are: %r or %r' %
30-
(QT_API_ENV, 'pyqt', 'pyside', 'pyqt5'))
30+
(QT_API_ENV, 'pyqt', 'pyside', 'pyqt5'))
3131
else:
3232
# No ETS environment, so use rcParams.
3333
if rcParams['backend'] == 'Qt5Agg':
@@ -70,8 +70,8 @@
7070
except:
7171
res = 'QVariant API v2 specification failed. Defaulting to v1.'
7272
verbose.report(cond+res, 'helpful')
73-
74-
if QT_API in [QT_API_PYQT, QT_API_PYQTv2]: # PyQt4 API
73+
74+
if QT_API in [QT_API_PYQT, QT_API_PYQTv2]: # PyQt4 API
7575

7676
from PyQt4 import QtCore, QtGui
7777

@@ -85,30 +85,28 @@
8585
except (AttributeError, KeyError):
8686
# call to getapi() can fail in older versions of sip
8787
_getSaveFileName = QtGui.QFileDialog.getSaveFileName
88-
89-
90-
else: # PyQt5 API
88+
89+
else: # PyQt5 API
9190

9291
from PyQt5 import QtCore, QtGui, QtWidgets
9392

9493
# Additional PyQt5 shimming to make it appear as for PyQt4
9594

9695
_get_save = QtWidgets.QFileDialog.getSaveFileName
9796
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
98-
97+
9998
# Alias PyQt-specific functions for PySide compatibility.
10099
QtCore.Signal = QtCore.pyqtSignal
101100
try:
102101
QtCore.Slot = QtCore.pyqtSlot
103102
except AttributeError:
104-
QtCore.Slot = pyqtSignature # Not a perfect match but
105-
# works in simple cases
103+
# Not a perfect match but works in simple cases
104+
QtCore.Slot = QtCore.pyqtSignature
105+
106106
QtCore.Property = QtCore.pyqtProperty
107107
__version__ = QtCore.PYQT_VERSION_STR
108108

109-
110-
111-
else: # try importing pyside
109+
else: # try importing pyside
112110
from PySide import QtCore, QtGui, __version__, __version_info__
113111
if __version_info__ < (1, 0, 3):
114112
raise ImportError(
@@ -122,11 +120,11 @@ def _getSaveFileName(self, msg, start, filters, selectedFilter):
122120

123121
# Apply shim to Qt4 APIs to make them look like Qt5
124122
if QT_API in (QT_API_PYQT, QT_API_PYQTv2, QT_API_PYSIDE):
125-
'''
126-
Import all used QtGui objects into QtWidgets
127-
128-
Here I've opted to simple copy QtGui into QtWidgets as that achieves the same result
129-
as copying over the objects, and will continue to work if other objects are used.
123+
'''Import all used QtGui objects into QtWidgets
124+
125+
Here I've opted to simple copy QtGui into QtWidgets as that
126+
achieves the same result as copying over the objects, and will
127+
continue to work if other objects are used.
128+
130129
'''
131130
QtWidgets = QtGui
132-

‎lib/matplotlib/backends/qt_editor/formsubplottool.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/qt_editor/formsubplottool.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from matplotlib.backends.qt_compat import QtCore, QtGui, QtWidgets
1212

13+
1314
class UiSubplotTool(QtWidgets.QDialog):
1415

1516
def __init__(self, *args, **kwargs):
@@ -217,7 +218,8 @@ def __init__(self, *args, **kwargs):
217218
gbox.addLayout(hbox2, 8, 0, 1, 1)
218219
self.tightlayout = QtWidgets.QPushButton('Tight Layout', self)
219220
spacer = QtWidgets.QSpacerItem(
220-
5, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
221+
5, 20, QtWidgets.QSizePolicy.Expanding,
222+
QtWidgets.QSizePolicy.Minimum)
221223
self.resetbutton = QtWidgets.QPushButton('Reset', self)
222224
self.donebutton = QtWidgets.QPushButton('Close', self)
223225
self.donebutton.setFocus()

‎lib/matplotlib/tests/test_coding_standards.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_coding_standards.py
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,8 @@
131131
'*/matplotlib/backends/backend_tkagg.py',
132132
'*/matplotlib/backends/backend_wx.py',
133133
'*/matplotlib/backends/backend_wxagg.py',
134-
'*/matplotlib/backends/qt4_compat.py',
135134
'*/matplotlib/backends/tkagg.py',
136135
'*/matplotlib/backends/windowing.py',
137-
'*/matplotlib/backends/qt_editor/figureoptions.py',
138136
'*/matplotlib/backends/qt_editor/formlayout.py',
139137
'*/matplotlib/sphinxext/ipython_console_highlighting.py',
140138
'*/matplotlib/sphinxext/ipython_directive.py',

0 commit comments

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