Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Rob Gaddi Newsgroups: comp.lang.python Subject: Re: How to access Qt components loaded from file? Date: Wed, 19 Nov 2014 12:56:12 -0800 Organization: Highland Technology, Inc. Lines: 67 Message-ID: <20141119125612.1f834ad5@rg.highlandtechnology.com> References: <546B3FE4.3050204@telenet.be> <546B6A4B.90107@telenet.be> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Info: mx02.eternal-september.org; posting-host="a48e804ab85e47f9d2e8748775b64aeb"; logging-data="21950"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18cfrdltXyn92rccdvRy8kF" X-Newsreader: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Cancel-Lock: sha1:lAqdnazpGeNjSB7reneANhX7eV4= Xref: csiph.com comp.lang.python:81041 On Wed, 19 Nov 2014 20:47:31 +0000 Juan Christian wrote: > Let's say that I want to call the site in a 5min interval. I'm currently > getting the info this way just for testing and to know that the 'core > engine' is working, and indeed, it's working: > > if __name__ == "__main__": > import sys > > app = QApplication(sys.argv) > MainWindow = loadui("main.ui") > > def output_slot(): > MainWindow.txtbox.setText(call_site()) > > MainWindow.btn.clicked.connect(output_slot) > > MainWindow.show() > app.exec_() > > How can I proceed if I want the txtbox to automatically do the > 'setText(call_site())' in a X defined interval? The final app will have not > only a txtbox, but a complete interface with buttons, avatar image, some > txtboxes, and all that stuff. If I know how to "call the site" in a defined > interval, I can get all the info that I need and set them one by one. > > If I'm not mistaken my app is locked in the app.exec_() loop, so I need to > have a trigger configured that will be called in a defined interval, then > inside this trigger I configure the "set_avatar", "set_text", > "set_btn_link", etc, is that right? > > On Tue Nov 18 2014 at 9:37:21 PM Chris Angelico wrote: > > > On Wed, Nov 19, 2014 at 5:15 AM, Juan Christian > > wrote: > > > > > > Thanks, it's working. What would be a "professional" approach if I want > > to > > > constantly call a URL to get it's content and access this data within the > > > GUI? > > > > > > > "Constantly" doesn't make much sense when you're talking about network > > operations. There are two basic approaches: either you re-fetch > > periodically and update the GUI (in which case you have to decide how > > frequently), or you re-fetch on some trigger (when it's changed, or > > when the user's about to need it, or something). Either way, you have > > to balance network traffic versus promptness of update, and it's > > nearly impossible to pick perfectly. But if you don't mind it being a > > little clunky, you should be able to pick something fairly simple and > > deploy it, and then maybe refine it a bit afterward. > > > > ChrisA > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > You'd use a QTimer to do that. Once you .start(5*60*1000) the timer, it'll fire a timeout signal every 5 minutes. You connect that timeout to the slots you want to execute if you don't care about order, or to a single slot function that runs the things that you want to do in some defined order. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix.