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

Fix handling of getSaveFileName to be consistent [backport to 1.4.x] #3469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 6, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix PEP8 compliance
  • Loading branch information
Martin Fitzpatrick committed Sep 5, 2014
commit c0fbfbd46571a8c5c414570a0ff618489a442835
15 changes: 7 additions & 8 deletions 15 lib/matplotlib/backends/backend_qt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from matplotlib._pylab_helpers import Gcf
from matplotlib.figure import Figure


from matplotlib.widgets import SubplotTool
try:
import matplotlib.backends.qt_editor.figureoptions as figureoptions
Expand Down Expand Up @@ -184,6 +183,7 @@ class TimerQT(TimerBase):
upon timer events. This list can be manipulated directly, or the
functions add_callback and remove_callback can be used.
'''

def __init__(self, *args, **kwargs):
TimerBase.__init__(self, *args, **kwargs)

Expand Down Expand Up @@ -331,8 +331,8 @@ def resizeEvent(self, event):
print('resize (%d x %d)' % (w, h))
print("FigureCanvasQt.resizeEvent(%d, %d)" % (w, h))
dpival = self.figure.dpi
winch = w/dpival
hinch = h/dpival
winch = w / dpival
hinch = h / dpival
self.figure.set_size_inches(winch, hinch)
FigureCanvasBase.resize_event(self)
self.draw()
Expand Down Expand Up @@ -551,9 +551,9 @@ def destroy(self, *args):
self.window.destroyed.connect(self._widgetclosed)

if self.toolbar:
self.toolbar.destroy()
self.toolbar.destroy()
if DEBUG:
print("destroy figure manager")
print("destroy figure manager")
self.window.close()

def get_window_title(self):
Expand Down Expand Up @@ -750,7 +750,7 @@ def __init__(self, targetfig, parent):
self.slidertop.valueChanged.connect(self.sliderbottom.setMaximum)

self.defaults = {}
for attr in ('left', 'bottom', 'right', 'top', 'wspace', 'hspace',):
for attr in ('left', 'bottom', 'right', 'top', 'wspace', 'hspace', ):
self.defaults[attr] = getattr(self.targetfig.subplotpars, attr)
slider = getattr(self, 'slider' + attr)
slider.setMinimum(0)
Expand All @@ -761,7 +761,7 @@ def __init__(self, targetfig, parent):
self._setSliderPositions()

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

Expand Down Expand Up @@ -850,6 +850,5 @@ def exception_handler(type, value, tb):
if len(msg):
error_msg_qt(msg)


FigureCanvas = FigureCanvasQT
FigureManager = FigureManagerQT
10 changes: 6 additions & 4 deletions 10 lib/matplotlib/backends/qt_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
QT_API_PYQT5 = 'PyQt5' # use PyQt5 API; Version 2 with module shim

ETS = dict(pyqt=QT_API_PYQTv2, pyside=QT_API_PYSIDE, pyqt5=QT_API_PYQT5)

# If the ETS QT_API environment variable is set, use it. Note that
# ETS requires the version 2 of PyQt4, which is not the platform
# default for Python 2.x.
Expand Down Expand Up @@ -62,14 +61,14 @@
sip.setapi('QString', 2)
except:
res = 'QString API v2 specification failed. Defaulting to v1.'
verbose.report(cond+res, 'helpful')
verbose.report(cond + res, 'helpful')
# condition has now been reported, no need to repeat it:
cond = ""
try:
sip.setapi('QVariant', 2)
except:
res = 'QVariant API v2 specification failed. Defaulting to v1.'
verbose.report(cond+res, 'helpful')
verbose.report(cond + res, 'helpful')

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

Expand All @@ -80,11 +79,15 @@
# Use new getSaveFileNameAndFilter()
_getSaveFileName = QtGui.QFileDialog.getSaveFileNameAndFilter
else:


# Use old getSaveFileName()
def _getSaveFileName(*args, **kwargs):
return QtGui.QFileDialog.getSaveFileName(*args, **kwargs), None

except (AttributeError, KeyError):


# call to getapi() can fail in older versions of sip
def _getSaveFileName(*args, **kwargs):
return QtGui.QFileDialog.getSaveFileName(*args, **kwargs), None
Expand Down Expand Up @@ -123,4 +126,3 @@ def _getSaveFileName(*args, **kwargs):

'''
QtWidgets = QtGui

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