Date: Sun, 21 Jan 2007 19:36:48 +0100
From: David Boddie <[EMAIL PROTECTED]>
Subject: Re: [PyKDE] callback not being called
To: [email protected]
Message-ID: < [EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"
On Sunday 21 January 2007 09:05:40 -0800, Tony Cappellini wrote:
Do you mean that you want to call normal methods in Python classes and not
j>>ust those supplied by their Qt base classes?
Yes
You should be able to use the same syntax as that used in the Qt
documentation, but there's also a PyQt-specific shortcut for slots that you
can use.
Well, the QT docs are all in C++, and often there are some differences for
python.
I've read the pyQT docs here, but it's very terse, and doesn't provide
examples.
http://www.riverbankcomputing.com/Docs/PyQt4/pyqt4ref.html#pyqt-slots-and-qt-slots
(this is the only python-specific help I can find. It's only one page)
3.5 Connecting Signals and
Slots<http://www.riverbankcomputing.com/Docs/PyQt4/pyqt4ref.html#id14>
Connections between signals and slots (and other signals) are made using the
QtCore.QObject.connect() method. For example:
QtCore.QObject.connect(a, QtCore.SIGNAL("QtSig()"), pyFunction)
QtCore.QObject.connect(a, QtCore.SIGNAL("QtSig()"), pyClass.pyMethod)
QtCore.QObject.connect(a, QtCore.SIGNAL
("QtSig()"), b, QtCore.SLOT("QtSlot()"))
QtCore.QObject.connect(a, QtCore.SIGNAL("PySig()"), b, QtCore.SLOT("QtSlot()"))
QtCore.QObject.connect(a, QtCore.SIGNAL("PySig"), pyFunction)
def updateTextBox(self):
# this function should be called, when the button is pressed
self.patchBrowser.setPlainText(self.tr("Callback was called"))
However, your updateTextBox() slot is just a normal Python method, so you
can just pass a reference to it:
>>self.connect(self.patchNames, QtCore.SIGNAL("activated()"),
self.updateTextBox)
I've tried this, my function still isn't being called
For slots defined by the C++ base class, you can use SLOT() to specify
them in the connect() call;
for example, the following connection would cause the dialog to be hidden
when a patchNames combobox entry is activated:
>>self.connect(self.patchNames, QtCore.SIGNAL("activated()"), self,
QtCore.SLOT("hide()"))
I've tried this too, it doesn't call my function either
_______________________________________________
PyKDE mailing list [email protected]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde