[PyQt] Autoconnecting two signals to the same method.

Rocco Orlando Rossi rocco.rossi at gmail.com
Sat Mar 15 08:31:14 GMT 2008


Hi all.

I'm new to PyQt. I'm coming from pygtk and Glade, but I am really very
interested in trying out PyQt, Eric, and Designer as a more valid
alternative.

Now, very briefly, here's my problem. I was attempting to autoconnect  two
different signals to the same method function, but I quickly realized that
it isn't at all obvious how to go about doing something like that. I thought
the decorator pyqtSignature might do the trick, but unfortunately chaining
those decorators did not work.

Any ideas?

Here's the example code I was working on:

#!/usr/bin/env python
import sys

from PyQt4 import QtCore, QtGui, uic

(form_class, base_class) = uic.loadUiType("qtui.ui")

class MyForm(form_class, base_class):
    def __init__(self, *args):
        base_class.__init__(self, *args)
        self.setupUi(self)

    @QtCore.pyqtSignature("on_pushButton1_clicked()")
    @QtCore.pyqtSignature("on_pushButton2_clicked()")
    def on_pushButton_clicked(self):
        print "Hi Man!"

app = QtGui.QApplication(sys.argv)
form = MyForm()
form.show()
app.exec_()

-- 
Rocco Rossi

-----------------------------------------------------------------

"Alcuni vedono le cose come sono e dicono perché? Io sogno cose non ancora
esistite e chiedo perché no?"

G.B. Shaw
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080315/79590474/attachment.html


More information about the PyQt mailing list