Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81007 > unrolled thread

Re: How to access Qt components loaded from file?

Started byVincent Vande Vyvre <vincent.vande.vyvre@telenet.be>
First post2014-11-18 16:48 +0100
Last post2014-11-18 16:48 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to access Qt components loaded from file? Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> - 2014-11-18 16:48 +0100

#81007 — Re: How to access Qt components loaded from file?

FromVincent Vande Vyvre <vincent.vande.vyvre@telenet.be>
Date2014-11-18 16:48 +0100
SubjectRe: How to access Qt components loaded from file?
Message-ID<mailman.15979.1416325737.18130.python-list@python.org>
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 
> <juan0christian@gmail.com <mailto:juan0christian@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())

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web