Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d3f8c3

Browse files
committed
PEP8 fixes to FigureManagerQT class
1 parent c3cb882 commit 3d3f8c3

File tree

1 file changed

+31
-24
lines changed

1 file changed

+31
-24
lines changed

lib/matplotlib/backends/backend_qt4.py

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,14 @@ def idle_draw(*args):
367367
self._idle = True
368368
if d: QtCore.QTimer.singleShot(0, idle_draw)
369369

370+
370371
class MainWindow(QtGui.QMainWindow):
371372
def closeEvent(self, event):
372373
self.emit(QtCore.SIGNAL('closing()'))
373374
QtGui.QMainWindow.closeEvent(self, event)
374375

375-
class FigureManagerQT( FigureManagerBase ):
376+
377+
class FigureManagerQT(FigureManagerBase):
376378
"""
377379
Public attributes
378380
@@ -382,30 +384,30 @@ class FigureManagerQT( FigureManagerBase ):
382384
window : The qt.QMainWindow
383385
"""
384386

385-
def __init__( self, canvas, num ):
386-
if DEBUG: print('FigureManagerQT.%s' % fn_name())
387-
FigureManagerBase.__init__( self, canvas, num )
387+
def __init__(self, canvas, num):
388+
if DEBUG:
389+
print('FigureManagerQT.%s' % fn_name())
390+
FigureManagerBase.__init__(self, canvas, num)
388391
self.canvas = canvas
389392
self.window = MainWindow()
390393
self.window.connect(self.window, QtCore.SIGNAL('closing()'),
391-
canvas.close_event)
392-
self.window.connect( self.window, QtCore.SIGNAL( 'closing()'),
393-
self._widgetclosed )
394+
canvas.close_event)
395+
self.window.connect(self.window, QtCore.SIGNAL('closing()'),
396+
self._widgetclosed)
394397

395398
self.window.setWindowTitle("Figure %d" % num)
396-
image = os.path.join( matplotlib.rcParams['datapath'],'images','matplotlib.png' )
397-
self.window.setWindowIcon(QtGui.QIcon( image ))
399+
image = os.path.join(matplotlib.rcParams['datapath'], 'images', 'matplotlib.png')
400+
self.window.setWindowIcon(QtGui.QIcon(image))
398401

399402
# Give the keyboard focus to the figure instead of the
400403
# manager; StrongFocus accepts both tab and click to focus and
401404
# will enable the canvas to process event w/o clicking.
402405
# ClickFocus only takes the focus is the window has been
403406
# clicked
404407
# on. http://developer.qt.nokia.com/doc/qt-4.8/qt.html#FocusPolicy-enum
405-
self.canvas.setFocusPolicy( QtCore.Qt.StrongFocus )
408+
self.canvas.setFocusPolicy(QtCore.Qt.StrongFocus)
406409
self.canvas.setFocus()
407410

408-
409411
self.window._destroying = False
410412

411413
self.toolbar = self._get_toolbar(self.canvas, self.window)
@@ -421,7 +423,7 @@ def __init__( self, canvas, num ):
421423
# requested size:
422424
cs = canvas.sizeHint()
423425
sbs = self.window.statusBar().sizeHint()
424-
self._status_and_tool_height = tbs_height+sbs.height()
426+
self._status_and_tool_height = tbs_height + sbs.height()
425427
height = cs.height() + self._status_and_tool_height
426428
self.window.resize(cs.width(), height)
427429

@@ -430,14 +432,14 @@ def __init__( self, canvas, num ):
430432
if matplotlib.is_interactive():
431433
self.window.show()
432434

433-
def notify_axes_change( fig ):
435+
def notify_axes_change(fig):
434436
# This will be called whenever the current axes is changed
435437
if self.toolbar is not None:
436438
self.toolbar.update()
437-
self.canvas.figure.add_axobserver( notify_axes_change )
439+
self.canvas.figure.add_axobserver(notify_axes_change)
438440

439441
@QtCore.Slot()
440-
def _show_message(self,s):
442+
def _show_message(self, s):
441443
# Fixes a PySide segfault.
442444
self.window.statusBar().showMessage(s)
443445

@@ -447,8 +449,9 @@ def full_screen_toggle(self):
447449
else:
448450
self.window.showFullScreen()
449451

450-
def _widgetclosed( self ):
451-
if self.window._destroying: return
452+
def _widgetclosed(self):
453+
if self.window._destroying:
454+
return
452455
self.window._destroying = True
453456
try:
454457
Gcf.destroy(self.num)
@@ -476,15 +479,19 @@ def resize(self, width, height):
476479
def show(self):
477480
self.window.show()
478481

479-
def destroy( self, *args ):
482+
def destroy(self, *args):
480483
# check for qApp first, as PySide deletes it in its atexit handler
481-
if QtGui.QApplication.instance() is None: return
482-
if self.window._destroying: return
484+
if QtGui.QApplication.instance() is None:
485+
return
486+
if self.window._destroying:
487+
return
483488
self.window._destroying = True
484-
QtCore.QObject.disconnect( self.window, QtCore.SIGNAL( 'destroyed()' ),
485-
self._widgetclosed )
486-
if self.toolbar: self.toolbar.destroy()
487-
if DEBUG: print("destroy figure manager")
489+
QtCore.QObject.disconnect(self.window, QtCore.SIGNAL('destroyed()'),
490+
self._widgetclosed)
491+
if self.toolbar:
492+
self.toolbar.destroy()
493+
if DEBUG:
494+
print("destroy figure manager")
488495
self.window.close()
489496

490497
def get_window_title(self):

0 commit comments

Comments
 (0)