Skip to content

New stlye qt calls #2382

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 8 commits into from
Sep 10, 2013
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
Next Next commit
second pass at catching the rest of the old-style signal/slot
connections.
  • Loading branch information
tacaswell committed Sep 5, 2013
commit bcdf5f5c7708ef1e6e62dacca1ab09cf2589503d
20 changes: 9 additions & 11 deletions lib/matplotlib/backends/backend_qt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,15 @@ def __init__(self, *args, **kwargs):
# Create a new timer and connect the timeout() signal to the
# _on_timer method.
self._timer = QtCore.QTimer()
QtCore.QObject.connect(self._timer, QtCore.SIGNAL('timeout()'),
self._on_timer)
self._timer.timeout.connect(self._on_timer)
self._timer_set_interval()

def __del__(self):
# Probably not necessary in practice, but is good behavior to
# disconnect
try:
TimerBase.__del__(self)
QtCore.QObject.disconnect(self._timer,
QtCore.SIGNAL('timeout()'), self._on_timer)
self._timer.timeout.disconnect(self._on_timer)
except RuntimeError:
# Timer C++ object already deleted
pass
Expand Down Expand Up @@ -422,8 +420,10 @@ def idle_draw(*args):


class MainWindow(QtGui.QMainWindow):
closing = QtCore.Signal()

def closeEvent(self, event):
self.emit(QtCore.SIGNAL('closing()'))
self.closing.emit()
QtGui.QMainWindow.closeEvent(self, event)


Expand All @@ -443,10 +443,8 @@ def __init__(self, canvas, num):
FigureManagerBase.__init__(self, canvas, num)
self.canvas = canvas
self.window = MainWindow()
self.window.connect(self.window, QtCore.SIGNAL('closing()'),
canvas.close_event)
self.window.connect(self.window, QtCore.SIGNAL('closing()'),
self._widgetclosed)
self.window.closing.connect(canvas.close_event)
self.window.closing.connect(self._widgetclosed)

self.window.setWindowTitle("Figure %d" % num)
image = os.path.join(matplotlib.rcParams['datapath'],
Expand Down Expand Up @@ -538,8 +536,8 @@ def destroy(self, *args):
if self.window._destroying:
return
self.window._destroying = True
QtCore.QObject.disconnect(self.window, QtCore.SIGNAL('destroyed()'),
self._widgetclosed)
self.window.destroyed.connect(self._widgetclosed)

if self.toolbar:
self.toolbar.destroy()
if DEBUG:
Expand Down
11 changes: 7 additions & 4 deletions lib/matplotlib/backends/qt4_editor/formlayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ def is_edit_valid(edit):


class FormWidget(QtGui.QWidget):
update_buttons = QtCore.Signal()
def __init__(self, data, comment="", parent=None):
QtGui.QWidget.__init__(self, parent)
from copy import deepcopy
Expand Down Expand Up @@ -292,8 +293,7 @@ def setup(self):
field.setValidator(QtGui.QDoubleValidator(field))
dialog = self.get_dialog()
dialog.register_float_field(field)
self.connect(field, QtCore.SIGNAL('textChanged(QString)'),
lambda text: dialog.update_buttons())
field.textChanged.connect(lambda text: dialog.update_buttons())
elif isinstance(value, int):
field = QtGui.QSpinBox(self)
field.setRange(-1e9, 1e9)
Expand Down Expand Up @@ -343,6 +343,8 @@ def get(self):


class FormComboWidget(QtGui.QWidget):
update_buttons = QtCore.Signal()

def __init__(self, datalist, comment="", parent=None):
QtGui.QWidget.__init__(self, parent)
layout = QtGui.QVBoxLayout()
Expand Down Expand Up @@ -370,6 +372,8 @@ def get(self):


class FormTabWidget(QtGui.QWidget):
update_buttons = QtCore.Signal()

def __init__(self, datalist, comment="", parent=None):
QtGui.QWidget.__init__(self, parent)
layout = QtGui.QVBoxLayout()
Expand Down Expand Up @@ -421,8 +425,7 @@ def __init__(self, data, title="", comment="",
# Button box
self.bbox = bbox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok
| QtGui.QDialogButtonBox.Cancel)
self.connect(self.formwidget, QtCore.SIGNAL('update_buttons()'),
self.update_buttons)
self.formwidget.update_buttons.connect(self.update_buttons)
if self.apply_callback is not None:
apply_btn = bbox.addButton(QtGui.QDialogButtonBox.Apply)
apply_btn.clicked.connect(self.apply)
Expand Down