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


Groups > comp.lang.python > #81007

Re: How to access Qt components loaded from file?

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <vincent.vande.vyvre@telenet.be>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'syntax': 0.04; 'subject:file': 0.07; 'correct,': 0.09; 'function:': 0.09; 'tests,': 0.09; 'worked.': 0.09; 'subject:How': 0.10; 'def': 0.12; 'random': 0.14; 'from:name:vincent vande vyvre': 0.16; 'func': 0.16; 'received:195.130': 0.16; 'received:195.130.137': 0.16; 'received:telenet-ops.be': 0.16; 'subject:access': 0.16; '\xe9crit': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'app': 0.19; 'header:User-Agent:1': 0.23; 'text.': 0.24; 'tue': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'url:mailman': 0.30; 'doc': 0.31; 'skip:m 60': 0.31; 'skip:q 20': 0.31; 'slot': 0.31; 'skip:m 30': 0.32; 'url:python': 0.33; 'subject:from': 0.34; 'problem': 0.35; "can't": 0.35; 'test': 0.35; 'but': 0.35; 'url:listinfo': 0.36; 'doing': 0.36; "i'll": 0.36; 'possible': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'christian': 0.38; 'nov': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'signal': 0.60; 'simple': 0.61; 'more': 0.64; 'charset:windows-1252': 0.65; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'regularly.': 0.84; 'why?': 0.91
Date Tue, 18 Nov 2014 16:48:27 +0100
From Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.2.0
MIME-Version 1.0
To python-list@python.org
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>
In-Reply-To <CAAp0bGu5z-jPm4cgm1u1CfwQPpDqy9G1A3ciwmaaSJcCrBeSPA@mail.gmail.com>
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 8bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To vincent.vandevyvre@oqapy.eu
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15979.1416325737.18130.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1416325737 news.xs4all.nl 2864 [2001:888:2000:d::a6]:53969
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81007

Show key headers only | View raw


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


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