8000 New stlye qt calls by tacaswell · Pull Request #2382 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

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
converted import-critical PyQt calls to new style so that it will
not seg-fault when using PySide

Addresses issue #2378
  • Loading branch information
tacaswell committed Sep 5, 2013
commit 7ddc5ee2cacaa48a77dbc21b6ef951644d004b26
52 changes: 16 additions & 36 deletions lib/matplotlib/backends/backend_qt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ def _create_qApp():
if display is None or not re.search(':\d', display):
raise RuntimeError('Invalid DISPLAY variable')

qApp = QtGui.QApplication([" "])
QtCore.QObject.connect(qApp, QtCore.SIGNAL("lastWindowClosed()"),
qApp, QtCore.SLOT("quit()"))
qApp = QtGui.QApplication([" "]) # probably fine, not used by QT to resolve anything
qApp.lastWindowClosed.connect(qApp.quit)
else:
qApp = app

Expand Down Expand Up @@ -469,8 +468,7 @@ def __init__(self, canvas, num):
self.toolbar = self._get_toolbar(self.canvas, self.window)
if self.toolbar is not None:
self.window.addToolBar(self.toolbar)
QtCore.QObject.connect(self.toolbar, QtCore.SIGNAL("message"),
self._show_message)
self.toolbar.message.connect(self._show_message)
tbs_height = self.toolbar.sizeHint().height()
else:
tbs_height = 0
Expand Down Expand Up @@ -556,6 +554,8 @@ def set_window_title(self, title):


class NavigationToolbar2QT(NavigationToolbar2, QtGui.QToolBar):
message = QtCore.Signal(str)

def __init__(self, canvas, parent, coordinates=True):
""" coordinates: should we show the coordinates on the right? """
self.canvas = canvas
Expand Down Expand Up @@ -656,7 +656,7 @@ def dynamic_update(self):
self.canvas.draw()

def set_message(self, s):
self.emit(QtCore.SIGNAL("message"), s)
self.message.emit(s)
if self.coordinates:
self.locLabel.setText(s.replace(', ', '\n'))

Expand Down Expand Up @@ -746,18 +746,10 @@ def __init__(self, targetfig, parent):
self.sliderhspace = QtGui.QSlider(QtCore.Qt.Vertical)

# constraints
QtCore.QObject.connect(self.sliderleft,
QtCore.SIGNAL("valueChanged(int)"),
self.sliderright.setMinimum)
QtCore.QObject.connect(self.sliderright,
QtCore.SIGNAL("valueChanged(int)"),
self.sliderleft.setMaximum)
QtCore.QObject.connect(self.sliderbottom,
QtCore.SIGNAL("valueChanged(int)"),
self.slidertop.setMinimum)
QtCore.QObject.connect(self.slidertop,
QtCore.SIGNAL("valueChanged(int)"),
self.sliderbottom.setMaximum)
self.sliderleft.valueChanged.connect(self.sliderright.setMinimum)
self.sliderright.valueChanged.connect(self.sliderleft.setMaximum)
self.sliderbottom.valueChanged.connect(self.slidertop.setMinimum)
self.slidertop.valueChanged.connect(self.sliderbottom.setMaximum)

sliders = (self.sliderleft, self.sliderbottom, self.sliderright,
self.slidertop, self.sliderwspace, self.sliderhspace,)
Expand Down Expand Up @@ -820,24 +812,12 @@ def __init__(self, targetfig, parent):
self.sliderhspace.setSliderPosition(
int(targetfig.subplotpars.hspace*1000))

QtCore.QObject.connect(self.sliderleft,
QtCore.SIGNAL("valueChanged(int)"),
self.funcleft)
QtCore.QObject.connect(self.sliderbottom,
QtCore.SIGNAL("valueChanged(int)"),
self.funcbottom)
QtCore.QObject.connect(self.sliderright,
QtCore.SIGNAL("valueChanged(int)"),
self.funcright)
QtCore.QObject.connect(self.slidertop,
QtCore.SIGNAL("valueChanged(int)"),
self.functop)
QtCore.QObject.connect(self.sliderwspace,
QtCore.SIGNAL("valueChanged(int)"),
self.funcwspace)
QtCore.QObject.connect(self.sliderhspace,
QtCore.SIGNAL("valueChanged(int)"),
self.funchspace)
self.sliderleft.valueChanged.connect(self.funcleft)
self.sliderbottom.valueChanged.connect(self.funcbottom)
self.sliderright.valueChanged.connect(self.funcright)
self.slidertop.valueChanged.connect(self.functop)
self.sliderwspace.valueChanged.connect(self.funcwspace)
self.sliderhspace.valueChanged.connect(self.funchspace)

def funcleft(self, val):
if val == self.sliderright.value():
Expand Down
28 changes: 13 additions & 15 deletions lib/matplotlib/backends/qt4_editor/formlayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,33 +70,33 @@ class ColorButton(QtGui.QPushButton):
"""
Color choosing push button
"""
__pyqtSignals__ = ("colorChanged(QColor)",)
colorChanged = QtCore.Signal(QtGui.QColor)

def __init__(self, parent=None):
QtGui.QPushButton.__init__(self, parent)
self.setFixedSize(20, 20)
self.setIconSize(QtCore.QSize(12, 12))
self.connect(self, QtCore.SIGNAL("clicked()"), self.choose_color)
self.clicked.connect(self.choose_color)
self._color = QtGui.QColor()

def choose_color(self):
color = QtGui.QColorDialog.getColor(self._color,self.parentWidget(),'')
color = QtGui.QColorDialog.getColor(self._color, self.parentWidget(), '')
if color.isValid():
self.set_color(color)

def get_color(self):
return self._color

@QtCore.Slot("QColor")
@QtCore.Slot(QtGui.QColor)
def set_color(self, color):
if color != self._color:
self._color = color
self.emit(QtCore.SIGNAL("colorChanged(QColor)"), self._color)
self.colorChanged.emit(self._color)
pixmap = QtGui.QPixmap(self.iconSize())
pixmap.fill(color)
self.setIcon(QtGui.QIcon(pixmap))

color = QtCore.Property("QColor", get_color, set_color)
color = QtCore.Property(QtGui.QColor, get_color, set_color)


def to_qcolor(color):
Expand All @@ -118,13 +118,11 @@ def __init__(self, color, parent=None):
QtGui.QHBoxLayout.__init__(self)
assert isinstance(color, QtGui.QColor)
self.lineedit = QtGui.QLineEdit(color.name(), parent)
self.connect(self.lineedit, QtCore.SIGNAL("editingFinished()"),
self.update_color)
self.lineedit.editingFinished.connect(self.update_color)
self.addWidget(self.lineedit)
self.colorbtn = ColorButton(parent)
self.colorbtn.color = color
self.connect(self.colorbtn, QtCore.SIGNAL("colorChanged(QColor)"),
self.update_text)
self.colorbtn.colorChanged.connect(self.update_text)
self.addWidget(self.colorbtn)

def update_color(self):
Expand Down Expand Up @@ -354,8 +352,7 @@ def __init__(self, datalist, comment="", parent=None):

self.stackwidget = QtGui.QStackedWidget(self)
layout.addWidget(self.stackwidget)
self.connect(self.combobox, QtCore.SIGNAL("currentIndexChanged(int)"),
self.stackwidget, QtCore.SLOT("setCurrentIndex(int)"))
self.combobox.currentIndexChanged.connect(self.stackwidget.setCurrentIndex)

self.widgetlist = []
for data, title, comment in datalist:
Expand Down Expand Up @@ -428,9 +425,10 @@ def __init__(self, data, title="", comment="",
self.update_buttons)
if self.apply_callback is not None:
apply_btn = bbox.addButton(QtGui.QDialogButtonBox.Apply)
self.connect(apply_btn, QtCore.SIGNAL("clicked()"), self.apply)
self.connect(bbox, QtCore.SIGNAL("accepted()"), QtCore.SLOT("accept()"))
self.connect(bbox, QtCore.SIGNAL("rejected()"), QtCore.SLOT("reject()"))
apply_btn.clicked.connect(self.apply)

bbox.accepted.connect(self.accept)
bbox.rejected.connect(self.reject)
layout.addWidget(bbox)

self.setLayout(layout)
Expand Down
0