0
votes

I'm trying to run the following PySide Qt Python example (code is at the bottom of this question):

https://github.com/Deusdies/pythonbo/blob/master/06-sixthTutorial-moresignals.py

I'm getting an error stating:

ASSERT: "pyMethod" in file /tmp/pyside-gUBW/pyside-qt4.8+1.1.2/libpyside/signalmanager.cpp, line 444

Any idea why this is happening at all, I'm running the code exactly as is, using Mac OS X 10.8.3. I have Python 2.7.4, as well as qt, and pyside installed via HomeBrew.

Any help would be appreciated!

import sys
from PySide.QtCore import *
from PySide.QtGui import *

class ZeroSpinBox(QSpinBox):

    zeros = 0

    def __init__(self, parent=None):
        super(ZeroSpinBox, self).__init__(parent)
        self.connect(self, SIGNAL("valueChanged(int)"), self.checkzero)

    def checkzero(self):
        if not self.value():
            self.zeros += 1
            self.nulls = 5
            self.emit(SIGNAL("atZero"), self.zeros, self.nulls)

class Form(QDialog):

    def __init__(self, parent=None):
        super(Form, self).__init__(parent)

        dial = QDial()
        dial.setNotchesVisible(True)

        zeroSpinBox = ZeroSpinBox()

        layout = QHBoxLayout()
        layout.addWidget(dial)
        layout.addWidget(zeroSpinBox)
        self.setLayout(layout)

        self.connect(dial, SIGNAL("valueChanged(int)"), zeroSpinBox.setValue)
        self.connect(zeroSpinBox, SIGNAL("valueChanged(int)"), dial.setValue)
        self.connect(zeroSpinBox, SIGNAL("atZero"), self.announce)

        self.setWindowTitle("Signals and Slots")

    def announce(self, zeros, nulls):
        print "Announcing!!!"

app = QApplication(sys.argv)
form = Form()
form.show()
app.exec_()

signalmanager.cpp

I managed to find a repository with the offending signalmanager.cpp source file online at :

https://github.com/jasonmccampbell/PySide/blob/master/libpyside/signalmanager.cpp#L444

Here's an excerpt from around line 444:

int SignalManager::callPythonMetaMethod(const QMetaMethod& method, void** args, PyObject* pyMethod, bool isShortCuit)
{
    Q_ASSERT(pyMethod); // This is the line causing the exception?

    Shiboken::GilState gil;
    PyObject* pyArguments = 0;
2
It's starting to look like development updates on PySide is rather slow? - josef.van.niekerk
I think PyQt might have a more active community. - phyatt
That's good to hear. I did some homework last night, and decided, despite everything else, I'll stick to PySide for now, due to their licensing. I'll switch if it gives definite problems that can't be worked around. - josef.van.niekerk

2 Answers

1
votes

http://qt-project.org/wiki/Signals_and_Slots_in_PySide

http://zetcode.com/tutorials/pyqt4/eventsandsignals/

PySide (or PyQt) signals and slots basics

http://qt-project.org/doc/qt-4.8/signalsandslots.html

I hope some of those links give you some ideas. The pyqt parser is probably struggling with linking your signal and slot, so it is complaining.

Isolate the problem to the single line of code (probably one of the connect calls), by putting some print statements in your code. Then simplify what you are doing to something that works, and then build up to what you want to do.

Hope that helps.

0
votes

I've found a fix, after watching the corresponding YouTube video at

http://www.youtube.com/watch?v=ooEzOyBiOLo.

The video does in fact explain this crash quite clearly, I was just trying the example without watching the video.

To fix the signals have to be defined as "atzero(int, int)" otherwise the application won't work.