Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81040 > unrolled thread
| Started by | Juan Christian <juan0christian@gmail.com> |
|---|---|
| First post | 2014-11-19 20:47 +0000 |
| Last post | 2014-11-22 18:15 -0800 |
| Articles | 12 — 5 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| From | Juan Christian <juan0christian@gmail.com> |
|---|---|
| Date | 2014-11-19 20:47 +0000 |
| Subject | Re: How to access Qt components loaded from file? |
| Message-ID | <mailman.16000.1416430060.18130.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
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@gmail.com> wrote:
> On Wed, Nov 19, 2014 at 5:15 AM, Juan Christian
> <juan0christian@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
>
[toc] | [next] | [standalone]
| From | Rob Gaddi <rgaddi@technologyhighland.invalid> |
|---|---|
| Date | 2014-11-19 12:56 -0800 |
| Message-ID | <20141119125612.1f834ad5@rg.highlandtechnology.com> |
| In reply to | #81040 |
On Wed, 19 Nov 2014 20:47:31 +0000
Juan Christian <juan0christian@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@gmail.com> wrote:
>
> > On Wed, Nov 19, 2014 at 5:15 AM, Juan Christian
> > <juan0christian@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.
[toc] | [prev] | [next] | [standalone]
| From | Juan Christian <juan0christian@gmail.com> |
|---|---|
| Date | 2014-11-20 02:53 +0000 |
| Message-ID | <mailman.16004.1416452037.18130.python-list@python.org> |
| In reply to | #81041 |
[Multipart message — attachments visible in raw view] — view raw
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?
On Wed Nov 19 2014 at 7:00:43 PM Rob Gaddi
<rgaddi@technologyhighland.invalid> wrote:
> On Wed, 19 Nov 2014 20:47:31 +0000
> Juan Christian <juan0christian@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@gmail.com>
> wrote:
> >
> > > On Wed, Nov 19, 2014 at 5:15 AM, Juan Christian
> > > <juan0christian@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.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
[toc] | [prev] | [next] | [standalone]
| From | Michael Torrie <torriem@gmail.com> |
|---|---|
| Date | 2014-11-20 08:37 -0700 |
| Message-ID | <mailman.16023.1416497853.18130.python-list@python.org> |
| In reply to | #81041 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Michael Torrie <torriem@gmail.com> |
|---|---|
| Date | 2014-11-20 08:41 -0700 |
| Message-ID | <mailman.16025.1416498105.18130.python-list@python.org> |
| In reply to | #81041 |
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? I clicked send too soon. The stackoverflow link is really referring to another link, which is much more complete and hopefully helpful to you: http://joplaete.wordpress.com/2010/07/21/threading-with-pyqt4/
[toc] | [prev] | [next] | [standalone]
| From | Juan Christian <juan0christian@gmail.com> |
|---|---|
| Date | 2014-11-20 17:57 +0000 |
| Message-ID | <mailman.16036.1416506256.18130.python-list@python.org> |
| In reply to | #81041 |
[Multipart message — attachments visible in raw view] — view raw
So, I need to study QThreads, do you know any book or video-course that talks about this matter? I've seen the tutorials that you pointed but I need a "wider" approach regarding QThreads to really understand it and apply it to my needs. The docs aren't that clear for me. On Thu Nov 20 2014 at 1:43:21 PM Michael Torrie <torriem@gmail.com> wrote: > 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? > > I clicked send too soon. The stackoverflow link is really referring to > another link, which is much more complete and hopefully helpful to you: > > http://joplaete.wordpress.com/2010/07/21/threading-with-pyqt4/ > > > -- > https://mail.python.org/mailman/listinfo/python-list >
[toc] | [prev] | [next] | [standalone]
| From | Michael Torrie <torriem@gmail.com> |
|---|---|
| Date | 2014-11-20 12:06 -0700 |
| Message-ID | <mailman.16042.1416510402.18130.python-list@python.org> |
| In reply to | #81041 |
On 11/20/2014 10:57 AM, Juan Christian wrote: > So, I need to study QThreads, do you know any book or video-course that > talks about this matter? I've seen the tutorials that you pointed but I > need a "wider" approach regarding QThreads to really understand it and > apply it to my needs. The docs aren't that clear for me. Yes you should definitely study up on QThreads. What is unclear about the docs? Which docs did you read? Did you read the links I sent you, particularly the wordpress blog post where he had a complete example (although I understand that it's not quite the correct way to do it)? What things have you tried searching for? Google reveals another discussion on stackoverflow which seems to give you a pretty complete, and correct, example: http://stackoverflow.com/questions/16241297/how-to-signal-from-a-running-qthread-back-to-the-pyqt-gui-that-started-it . Note that the first post there is not working, but the fix is listed in the second post. Put them together and you'll have a working example.
[toc] | [prev] | [next] | [standalone]
| From | Juan Christian <juan0christian@gmail.com> |
|---|---|
| Date | 2014-11-20 19:36 +0000 |
| Message-ID | <mailman.16046.1416512206.18130.python-list@python.org> |
| In reply to | #81041 |
[Multipart message — attachments visible in raw view] — view raw
Yes, I read everything and saw that stackoverlfow on Google too. I'm reading this doc: http://pyqt.sourceforge.net/Docs/PyQt4/classes.html I just asked for a book because normally there are books for anything =p On Thu Nov 20 2014 at 5:08:09 PM Michael Torrie <torriem@gmail.com> wrote: > On 11/20/2014 10:57 AM, Juan Christian wrote: > > So, I need to study QThreads, do you know any book or video-course that > > talks about this matter? I've seen the tutorials that you pointed but I > > need a "wider" approach regarding QThreads to really understand it and > > apply it to my needs. The docs aren't that clear for me. > > Yes you should definitely study up on QThreads. What is unclear about > the docs? Which docs did you read? Did you read the links I sent you, > particularly the wordpress blog post where he had a complete example > (although I understand that it's not quite the correct way to do it)? > What things have you tried searching for? > > Google reveals another discussion on stackoverflow which seems to give > you a pretty complete, and correct, example: > http://stackoverflow.com/questions/16241297/how-to- > signal-from-a-running-qthread-back-to-the-pyqt-gui-that-started-it > . Note that the first post there is not working, but the fix is listed > in the second post. Put them together and you'll have a working example. > -- > https://mail.python.org/mailman/listinfo/python-list >
[toc] | [prev] | [next] | [standalone]
| From | Juan Christian <juan0christian@gmail.com> |
|---|---|
| Date | 2014-11-20 19:37 +0000 |
| Message-ID | <mailman.16048.1416512249.18130.python-list@python.org> |
| In reply to | #81041 |
[Multipart message — attachments visible in raw view] — view raw
Another problem is that this doc doesn't use Python. On Thu Nov 20 2014 at 5:36:37 PM Juan Christian <juan0christian@gmail.com> wrote: > Yes, I read everything and saw that stackoverlfow on Google too. I'm > reading this doc: http://pyqt.sourceforge.net/Docs/PyQt4/classes.html > > I just asked for a book because normally there are books for anything =p > > On Thu Nov 20 2014 at 5:08:09 PM Michael Torrie <torriem@gmail.com> wrote: > >> On 11/20/2014 10:57 AM, Juan Christian wrote: >> > So, I need to study QThreads, do you know any book or video-course that >> > talks about this matter? I've seen the tutorials that you pointed but I >> > need a "wider" approach regarding QThreads to really understand it and >> > apply it to my needs. The docs aren't that clear for me. >> >> Yes you should definitely study up on QThreads. What is unclear about >> the docs? Which docs did you read? Did you read the links I sent you, >> particularly the wordpress blog post where he had a complete example >> (although I understand that it's not quite the correct way to do it)? >> What things have you tried searching for? >> >> Google reveals another discussion on stackoverflow which seems to give >> you a pretty complete, and correct, example: >> http://stackoverflow.com/questions/16241297/how-to-signal- >> from-a-running-qthread-back-to-the-pyqt-gui-that-started-it >> . Note that the first post there is not working, but the fix is listed >> in the second post. Put them together and you'll have a working example. >> -- >> https://mail.python.org/mailman/listinfo/python-list >> >
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-11-20 21:06 +0000 |
| Message-ID | <mailman.16055.1416517600.18130.python-list@python.org> |
| In reply to | #81041 |
On 20/11/2014 17:57, Juan Christian wrote: > So, I need to study QThreads, do you know any book or video-course that > talks about this matter? I've seen the tutorials that you pointed but I > need a "wider" approach regarding QThreads to really understand it and > apply it to my needs. The docs aren't that clear for me. > You also need to study the difference between top posting, interspersed posting and bottom posting. The second and third are very much the prefered styles here. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Juan Christian <juan0christian@gmail.com> |
|---|---|
| Date | 2014-11-20 21:19 +0000 |
| Message-ID | <mailman.16057.1416518371.18130.python-list@python.org> |
| In reply to | #81041 |
[Multipart message — attachments visible in raw view] — view raw
On Thu Nov 20 2014 at 7:07:10 PM Mark Lawrence <breamoreboy@yahoo.co.uk> wrote: > > You also need to study the difference between top posting, interspersed > posting and bottom posting. The second and third are very much the > prefered styles here. > Yes I know, but I'm using the new Google Inbox, and I limited to what I can do when replying, to do the right way I have to do many steps now...
[toc] | [prev] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2014-11-22 18:15 -0800 |
| Message-ID | <997689f9-e2de-4e30-a7f3-bdf6f760b146@googlegroups.com> |
| In reply to | #81127 |
On Friday, November 21, 2014 2:49:45 AM UTC+5:30, Juan Christian wrote: > On Thu Nov 20 2014 at 7:07:10 PM Mark Lawrence wrote: > You also need to study the difference between top posting, interspersed > > posting and bottom posting. The second and third are very much the > > prefered styles here. > > > > Yes I know, but I'm using the new Google Inbox, and I limited to what I can do when replying, to do the right way I have to do many steps now... In gmail 'compose-box' there is a small downward triangle at the right bottom of screen. That allows you to choose plain text mode.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web