Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81007
| Date | 2014-11-18 16:48 +0100 |
|---|---|
| From | Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> |
| Subject | Re: How to access Qt components loaded from file? |
| References | <CAAp0bGvE_4gONgiAOjW7K2XNY7cUJz5xPB7o9rGdGS=BXCwHCQ@mail.gmail.com> <546B3FE4.3050204@telenet.be> <CAAp0bGuiJaU6jeK5uzwyhfax1tm5PBesxwByt-En5mU2v0+8Zg@mail.gmail.com> <CAAp0bGu5z-jPm4cgm1u1CfwQPpDqy9G1A3ciwmaaSJcCrBeSPA@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.15979.1416325737.18130.python-list@python.org> (permalink) |
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())
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How to access Qt components loaded from file? Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> - 2014-11-18 16:48 +0100
csiph-web