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


Groups > comp.lang.python > #81005

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>
From Juan Christian <juan0christian@gmail.com>
Date 2014-11-18 14:49 +0000
Subject Re: How to access Qt components loaded from file?
Newsgroups comp.lang.python
Message-ID <mailman.15977.1416322150.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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>
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. ^^
>
> On Tue Nov 18 2014 at 10:48:44 AM Vincent Vande Vyvre <
> vincent.vande.vyvre@telenet.be> wrote:
>
>> Le 18/11/2014 13:18, Juan Christian a écrit :
>> > I have this simple code that load any Qt Designer .UI file:
>> >
>> > from PySide.QtCore import QFile
>> > from PySide.QtGui import QApplication
>> > from PySide.QtUiTools import QUiLoader
>> >
>> >
>> > def loadui(file_name):
>> > loader = QUiLoader()
>> > uifile = QFile(file_name)
>> > uifile.open(QFile.ReadOnly)
>> > ui = loader.load(uifile)
>> > uifile.close()
>> > return ui
>> >
>> >
>> > if __name__ == "__main__":
>> > import sys
>> >
>> > app = QApplication(sys.argv)
>> > MainWindow = loadui("main.ui")
>> > MainWindow.show()
>> > app.exec_()
>> >
>> > Let's say I have a QTextEdit called txtbox. How can I access this
>> > txtbox inside my Python code?
>> >
>> >
>> How about MainWindow.txtbox  ?
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: How to access Qt components loaded from file? Juan Christian <juan0christian@gmail.com> - 2014-11-18 14:49 +0000

csiph-web