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 b892838

Browse filesBrowse files
committed
Merge pull request #3469 from mfitzp
Fixed pep8 and merged to master locally
2 parents 7b9d215 + 6b9037c commit b892838
Copy full SHA for b892838

File tree

Expand file treeCollapse file tree

2 files changed

+21
-24
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+21
-24
lines changed

‎lib/matplotlib/backends/backend_qt5.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt5.py
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from matplotlib._pylab_helpers import Gcf
2323
from matplotlib.figure import Figure
2424

25-
2625
from matplotlib.widgets import SubplotTool
2726
try:
2827
import matplotlib.backends.qt_editor.figureoptions as figureoptions
@@ -184,6 +183,7 @@ class TimerQT(TimerBase):
184183
upon timer events. This list can be manipulated directly, or the
185184
functions add_callback and remove_callback can be used.
186185
'''
186+
187187
def __init__(self, *args, **kwargs):
188188
TimerBase.__init__(self, *args, **kwargs)
189189

@@ -331,8 +331,8 @@ def resizeEvent(self, event):
331331
print('resize (%d x %d)' % (w, h))
332332
print("FigureCanvasQt.resizeEvent(%d, %d)" % (w, h))
333333
dpival = self.figure.dpi
334-
winch = w/dpival
335-
hinch = h/dpival
334+
winch = w / dpival
335+
hinch = h / dpival
336336
self.figure.set_size_inches(winch, hinch)
337337
FigureCanvasBase.resize_event(self)
338338
self.draw()
@@ -551,9 +551,9 @@ def destroy(self, *args):
551551
self.window.destroyed.connect(self._widgetclosed)
552552

553553
if self.toolbar:
554-
self.toolbar.destroy()
554+
self.toolbar.destroy()
555555
if DEBUG:
556-
print("destroy figure manager")
556+
print("destroy figure manager")
557557
self.window.close()
558558

559559
def get_window_title(self):
@@ -715,7 +715,8 @@ def save_figure(self, *args):
715715
filters.append(filter)
716716
filters = ';;'.join(filters)
717717

718-
fname = _getSaveFileName(self.parent, "Choose a filename to save to",
718+
fname, filter = _getSaveFileName(self.parent,
719+
"Choose a filename to save to",
719720
start, filters, selectedFilter)
720721
if fname:
721722
if startpath == '':
@@ -750,7 +751,7 @@ def __init__(self, targetfig, parent):
750751
self.slidertop.valueChanged.connect(self.sliderbottom.setMaximum)
751752

752753
self.defaults = {}
753-
for attr in ('left', 'bottom', 'right', 'top', 'wspace', 'hspace',):
754+
for attr in ('left', 'bottom', 'right', 'top', 'wspace', 'hspace', ):
754755
self.defaults[attr] = getattr(self.targetfig.subplotpars, attr)
755756
slider = getattr(self, 'slider' + attr)
756757
slider.setMinimum(0)
@@ -761,7 +762,7 @@ def __init__(self, targetfig, parent):
761762
self._setSliderPositions()
762763

763764
def _setSliderPositions(self):
764-
for attr in ('left', 'bottom', 'right', 'top', 'wspace', 'hspace',):
765+
for attr in ('left', 'bottom', 'right', 'top', 'wspace', 'hspace', ):
765766
slider = getattr(self, 'slider' + attr)
766767
slider.setSliderPosition(int(self.defaults[attr] * 1000))
767768

@@ -850,6 +851,5 @@ def exception_handler(type, value, tb):
850851
if len(msg):
851852
error_msg_qt(msg)
852853

853-
854854
FigureCanvas = FigureCanvasQT
855855
FigureManager = FigureManagerQT

‎lib/matplotlib/backends/qt_compat.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/qt_compat.py
+12-15Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
QT_API_PYQT5 = 'PyQt5' # use PyQt5 API; Version 2 with module shim
1616

1717
ETS = dict(pyqt=QT_API_PYQTv2, pyside=QT_API_PYSIDE, pyqt5=QT_API_PYQT5)
18-
1918
# If the ETS QT_API environment variable is set, use it. Note that
2019
# ETS requires the version 2 of PyQt4, which is not the platform
2120
# default for Python 2.x.
@@ -62,14 +61,14 @@
6261
sip.setapi('QString', 2)
6362
except:
6463
res = 'QString API v2 specification failed. Defaulting to v1.'
65-
verbose.report(cond+res, 'helpful')
64+
verbose.report(cond + res, 'helpful')
6665
# condition has now been reported, no need to repeat it:
6766
cond = ""
6867
try:
6968
sip.setapi('QVariant', 2)
7069
except:
7170
res = 'QVariant API v2 specification failed. Defaulting to v1.'
72-
verbose.report(cond+res, 'helpful')
71+
verbose.report(cond + res, 'helpful')
7372

7473
if QT_API in [QT_API_PYQT, QT_API_PYQTv2]: # PyQt4 API
7574

@@ -78,21 +77,22 @@
7877
try:
7978
if sip.getapi("QString") > 1:
8079
# Use new getSaveFileNameAndFilter()
81-
_get_save = QtGui.QFileDialog.getSaveFileNameAndFilter
80+
_getSaveFileName = QtGui.QFileDialog.getSaveFileNameAndFilter
8281
else:
82+
8383
# Use old getSaveFileName()
84-
_getSaveFileName = QtGui.QFileDialog.getSaveFileName
84+
def _getSaveFileName(*args, **kwargs):
85+
return (QtGui.QFileDialog.getSaveFileName(*args, **kwargs),
86+
None)
87+
8588
except (AttributeError, KeyError):
89+
8690
# call to getapi() can fail in older versions of sip
87-
_getSaveFileName = QtGui.QFileDialog.getSaveFileName
91+
def _getSaveFileName(*args, **kwargs):
92+
return QtGui.QFileDialog.getSaveFileName(*args, **kwargs), None
8893

8994
else: # PyQt5 API
90-
9195
from PyQt5 import QtCore, QtGui, QtWidgets
92-
93-
# Additional PyQt5 shimming to make it appear as for PyQt4
94-
95-
_get_save = QtWidgets.QFileDialog.getSaveFileName
9696
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
9797

9898
# Alias PyQt-specific functions for PySide compatibility.
@@ -112,11 +112,8 @@
112112
raise ImportError(
113113
"Matplotlib backend_qt4 and backend_qt4agg require PySide >=1.0.3")
114114

115-
_get_save = QtGui.QFileDialog.getSaveFileName
115+
_getSaveFileName = QtGui.QFileDialog.getSaveFileName
116116

117-
if _getSaveFileName is None:
118-
def _getSaveFileName(self, msg, start, filters, selectedFilter):
119-
return _get_save(self, msg, start, filters, selectedFilter)[0]
120117

121118
# Apply shim to Qt4 APIs to make them look like Qt5
122119
if QT_API in (QT_API_PYQT, QT_API_PYQTv2, QT_API_PYSIDE):

0 commit comments

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