Le 18/11/2014 15:49, Juan Christian a écrit :
I was doing some tests, then I tried this:

app = QApplication(sys.argv)
MainWindow = loadui("main.ui")
MainWindow.btn.clicked.connect(MainWindow.txtbox.setText(test()))

MainWindow.show()
app.exec_()

But I get "RuntimeError: Failed to connect signal clicked().", why?

The syntax is correct, I don't know why it failed, the btn is in the Form too, it's a QPushButton.

The test func is just a simple func that returns a random text.

On Tue Nov 18 2014 at 11:08:48 AM Juan Christian <juan0christ...@gmail.com <mailto:juan0christ...@gmail.com>> wrote:

    Many thanks, worked. The only problem now is that I don't have
    auto-complete for anything, because of this approach... I'll have
    to check the doc more regularly. ^^

    ....

        https://mail.python.org/mailman/listinfo/python-list



You can't have a slot like this:

MainWindow.btn.clicked.connect(MainWindow.txtbox.setText(test()))

because that's mean: "connect to the return of MainWindow.txtbox.setText(test())" and it's not possible at this stage of your program.

Use instead a function:

MainWindow.btn.clicked.connect(my_slot) # No parenthesis !

def my_slot():
    MainWindow.txtbox.setText(test())
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to