How to access Qt components loaded from file?

Rob Gaddi rgaddi at technologyhighland.invalid
Wed Nov 19 15:56:12 EST 2014


On Wed, 19 Nov 2014 20:47:31 +0000
Juan Christian <juan0christian at gmail.com> 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 <rosuav at gmail.com> wrote:
> 
> > On Wed, Nov 19, 2014 at 5:15 AM, Juan Christian
> > <juan0christian at gmail.com> 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.



More information about the Python-list mailing list