Skip to content

Commit bcdf5f5

Browse files
committed
second pass at catching the rest of the old-style signal/slot
connections.
1 parent bf3b1b4 commit bcdf5f5

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

lib/matplotlib/backends/backend_qt4.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,15 @@ def __init__(self, *args, **kwargs):
133133
# Create a new timer and connect the timeout() signal to the
134134
# _on_timer method.
135135
self._timer = QtCore.QTimer()
136-
QtCore.QObject.connect(self._timer, QtCore.SIGNAL('timeout()'),
137-
self._on_timer)
136+
self._timer.timeout.connect(self._on_timer)
138137
self._timer_set_interval()
139138

140139
def __del__(self):
141140
# Probably not necessary in practice, but is good behavior to
142141
# disconnect
143142
try:
144143
TimerBase.__del__(self)
145-
QtCore.QObject.disconnect(self._timer,
146-
QtCore.SIGNAL('timeout()'), self._on_timer)
144+
self._timer.timeout.disconnect(self._on_timer)
147145
except RuntimeError:
148146
# Timer C++ object already deleted
149147
pass
@@ -422,8 +420,10 @@ def idle_draw(*args):
422420

423421

424422
class MainWindow(QtGui.QMainWindow):
423+
closing = QtCore.Signal()
424+
425425
def closeEvent(self, event):
426-
self.emit(QtCore.SIGNAL('closing()'))
426+
self.closing.emit()
427427
QtGui.QMainWindow.closeEvent(self, event)
428428

429429

@@ -443,10 +443,8 @@ def __init__(self, canvas, num):
443443
FigureManagerBase.__init__(self, canvas, num)
444444
self.canvas = canvas
445445
self.window = MainWindow()
446-
self.window.connect(self.window, QtCore.SIGNAL('closing()'),
447-
canvas.close_event)
448-
self.window.connect(self.window, QtCore.SIGNAL('closing()'),
449-
self._widgetclosed)
446+
self.window.closing.connect(canvas.close_event)
447+
self.window.closing.connect(self._widgetclosed)
450448

451449
self.window.setWindowTitle("Figure %d" % num)
452450
image = os.path.join(matplotlib.rcParams['datapath'],
@@ -538,8 +536,8 @@ def destroy(self, *args):
538536
if self.window._destroying:
539537
return
540538
self.window._destroying = True
541-
QtCore.QObject.disconnect(self.window, QtCore.SIGNAL('destroyed()'),
542-
self._widgetclosed)
539+
self.window.destroyed.connect(self._widgetclosed)
540+
543541
if self.toolbar:
544542
self.toolbar.destroy()
545543
if DEBUG:

lib/matplotlib/backends/qt4_editor/formlayout.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ def is_edit_valid(edit):
218218

219219

220220
class FormWidget(QtGui.QWidget):
221+
update_buttons = QtCore.Signal()
221222
def __init__(self, data, comment="", parent=None):
222223
QtGui.QWidget.__init__(self, parent)
223224
from copy import deepcopy
@@ -292,8 +293,7 @@ def setup(self):
292293
field.setValidator(QtGui.QDoubleValidator(field))
293294
dialog = self.get_dialog()
294295
dialog.register_float_field(field)
295-
self.connect(field, QtCore.SIGNAL('textChanged(QString)'),
296-
lambda text: dialog.update_buttons())
296+
field.textChanged.connect(lambda text: dialog.update_buttons())
297297
elif isinstance(value, int):
298298
field = QtGui.QSpinBox(self)
299299
field.setRange(-1e9, 1e9)
@@ -343,6 +343,8 @@ def get(self):
343343

344344

345345
class FormComboWidget(QtGui.QWidget):
346+
update_buttons = QtCore.Signal()
347+
346348
def __init__(self, datalist, comment="", parent=None):
347349
QtGui.QWidget.__init__(self, parent)
348350
layout = QtGui.QVBoxLayout()
@@ -370,6 +372,8 @@ def get(self):
370372

371373

372374
class FormTabWidget(QtGui.QWidget):
375+
update_buttons = QtCore.Signal()
376+
373377
def __init__(self, datalist, comment="", parent=None):
374378
QtGui.QWidget.__init__(self, parent)
375379
layout = QtGui.QVBoxLayout()
@@ -421,8 +425,7 @@ def __init__(self, data, title="", comment="",
421425
# Button box
422426
self.bbox = bbox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok
423427
| QtGui.QDialogButtonBox.Cancel)
424-
self.connect(self.formwidget, QtCore.SIGNAL('update_buttons()'),
425-
self.update_buttons)
428+
self.formwidget.update_buttons.connect(self.update_buttons)
426429
if self.apply_callback is not None:
427430
apply_btn = bbox.addButton(QtGui.QDialogButtonBox.Apply)
428431
apply_btn.clicked.connect(self.apply)

0 commit comments

Comments
 (0)