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


Groups > comp.lang.python > #81081

Re: How to access Qt components loaded from file?

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <torriem+gmail@torriefamily.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'url:sourceforge': 0.03; 'subject:file': 0.07; 'apis': 0.09; 'callback': 0.09; 'subject:How': 0.10; 'gui': 0.12; 'thread': 0.14; "(i'm": 0.16; 'api,': 0.16; 'complete;': 0.16; 'emit': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'helps.': 0.16; 'normal,': 0.16; 'pythonic': 0.16; 'retrieving': 0.16; 'spawn': 0.16; 'subject:access': 0.16; 'thread,': 0.16; 'typically.': 0.16; 'url:html)': 0.16; 'urllib2,': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; "python's": 0.19; 'example': 0.22; 'load': 0.23; 'header:User-Agent:1': 0.23; "aren't": 0.24; "shouldn't": 0.24; 'task': 0.26; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'bunch': 0.31; 'subject:from': 0.34; 'something': 0.35; 'case,': 0.35; 'but': 0.35; 'google': 0.35; 'complete.': 0.36; 'library.': 0.36; 'right?': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'should': 0.36; 'example,': 0.37; 'christian': 0.38; 'message-id:@gmail.com': 0.38; 'handle': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'hope': 0.61; 'new': 0.61; 'information,': 0.61; 'simple': 0.61; "you'll": 0.62; '(that': 0.65; 'content,': 0.68; 'heavy': 0.81; 'asynchronous': 0.84
X-Virus-Scanned amavisd-new at torriefamily.org
Date Thu, 20 Nov 2014 08:37:15 -0700
From Michael Torrie <torriem@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131118 Thunderbird/17.0.11
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> <546B6A4B.90107@telenet.be> <CAAp0bGttSSzLL_K_vzWRb+E+mAHdSYVk-8PSARFKG=JWJ4rMng@mail.gmail.com> <CAPTjJmpxbnMKFwcb+JFZtCS2yFTEWK7M58NdPUMNPmxLqFw0dQ@mail.gmail.com> <mailman.16000.1416430060.18130.python-list@python.org> <20141119125612.1f834ad5@rg.highlandtechnology.com> <CAAp0bGsCL9CKzzeZVZkEqjX_6BjLbgX0P2mRcmp3zBKDKEzL1Q@mail.gmail.com>
In-Reply-To <CAAp0bGsCL9CKzzeZVZkEqjX_6BjLbgX0P2mRcmp3zBKDKEzL1Q@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
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.16023.1416497853.18130.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1416497853 news.xs4all.nl 2951 [2001:888:2000:d::a6]:42538
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81081

Show key headers only | View raw


On 11/19/2014 07:53 PM, Juan Christian wrote:
> Thanks, it's working using QTimer. The thing is that whenever the program
> is going to do something, in my case, draw a new QGroupBox with some
> components inside and put it in the Form (I'm using VBoxLayout in the main
> form) the program freezes, and I'm using very simple components just for
> testing.This shouldn't be normal, right?
> 
> Am I doing something wrong?

Make sure your callbacks always return very quickly.  Never do any long
task in a GUI event callback.  Even your timer event callbacks should
return quickly.  If you need to do something that takes longer, like
load a web page from a url, you need to either do it asynchronously with
Qt's API, or spawn a thread to do the heavy lifting.  Qt provides a
whole bunch of apis for doing this (that overlap python's standard
library.  For example, instead of urllib2, there's QNetwork
(http://pyqt.sourceforge.net/Docs/PyQt4/qtnetwork.html) that provides an
asynchronous means of doing sockets, retrieving web content, etc.  They
aren't very pythonic probably, but they do all emit signals upon
completion, so yo don't have to sit in a callback waiting for the
download to complete.

If you do want to spawn a thread to handle your longer-running task
(normal urllib2), you'll have to come up with a way of notifying the
main thread that the download is complete; you shouldn't call any GUI
calls from the thread, typically.  Here's an example of how to have a
thread notify the main loop of completion:

http://stackoverflow.com/questions/16879971/example-of-the-right-way-to-use-qthread-in-pyqt

A quick google can reveal all this information, but it's harder if you
don't know what to look for.  So I hope this helps.

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


Thread

Re: How to access Qt components loaded from file? Juan Christian <juan0christian@gmail.com> - 2014-11-19 20:47 +0000
  Re: How to access Qt components loaded from file? Rob Gaddi <rgaddi@technologyhighland.invalid> - 2014-11-19 12:56 -0800
    Re: How to access Qt components loaded from file? Juan Christian <juan0christian@gmail.com> - 2014-11-20 02:53 +0000
    Re: How to access Qt components loaded from file? Michael Torrie <torriem@gmail.com> - 2014-11-20 08:37 -0700
    Re: How to access Qt components loaded from file? Michael Torrie <torriem@gmail.com> - 2014-11-20 08:41 -0700
    Re: How to access Qt components loaded from file? Juan Christian <juan0christian@gmail.com> - 2014-11-20 17:57 +0000
    Re: How to access Qt components loaded from file? Michael Torrie <torriem@gmail.com> - 2014-11-20 12:06 -0700
    Re: How to access Qt components loaded from file? Juan Christian <juan0christian@gmail.com> - 2014-11-20 19:36 +0000
    Re: How to access Qt components loaded from file? Juan Christian <juan0christian@gmail.com> - 2014-11-20 19:37 +0000
    Re: How to access Qt components loaded from file? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-20 21:06 +0000
    Re: How to access Qt components loaded from file? Juan Christian <juan0christian@gmail.com> - 2014-11-20 21:19 +0000
      Re: How to access Qt components loaded from file? Rustom Mody <rustompmody@gmail.com> - 2014-11-22 18:15 -0800

csiph-web