[ploting data] Live data

If I'm understanding your question correctly and reading your code correctly, you're asking why the timer method of doing things works, but the principal() while loop method does not.

I had a couple solutions that involved the main event loop, but I just noticed 2 main things that are probably wrong with your code:
1. You are calling 'principal' from inside __init__ so you never actually return from __init__ which means that you never call "window.show()" and therefore never call "qApp.exec_()". If you really want to use the 'principal' method you would have to connect it to a one shot timer anyway to have it run after you have started the application ('qApp.exec_()'). I think the recommended way would be to use the timer the way you did in your latest email.

2. At least in the way my email client reads your original code, your calls to the matplotlib drawing functions aren't inside the while loop and the while loop never ends...although this doesn't matter if you don't fix #1 above.

Hope that made sense.

-Dave

···

On 12/5/11 1:44 PM, matplotlib-users-request@lists.sourceforge.net wrote:

Message: 3
Date: Mon, 5 Dec 2011 15:46:02 +0100
From: Fabien Lafont<lafont.fabien@...287...>
Subject: Re: [Matplotlib-users] [ploting data] Live data
Cc:matplotlib-users@lists.sourceforge.net
Message-ID:
  <CAC9H_cjrgQBE6e6+jzZHyfYHonTeAg0XwU7c_2G-hu=s+Z7OFQ@...288...>
Content-Type: text/plain; charset=ISO-8859-1

Thx all for your remarks,

I can't understand why this code works (when I use the timer method):

Hi David! Sorry about the delay I was abroad and without any way to
connect to the internet.

Thank you very much. I've tried to put the principal inside the
timerEvent. It work but it lags. In fact I've set the interval of the
Timer to 2 seconds because the principal loop takes roughly 2seconds
but it's not very accurate...

Is there a way to do the principal loop, show it on the screen, then
redo the loop?

Thanks again!

Fabien

2011/12/5 David Hoese <dhoese@...287...>:

···

If I'm understanding your question correctly and reading your code correctly, you're asking why the timer method of doing things works, but the principal() while loop method does not.

I had a couple solutions that involved the main event loop, but I just noticed 2 main things that are probably wrong with your code:
1. You are calling 'principal' from inside __init__ so you never actually return from __init__ which means that you never call "window.show()" and therefore never call "qApp.exec_()". If you really want to use the 'principal' method you would have to connect it to a one shot timer anyway to have it run after you have started the application ('qApp.exec_()'). I think the recommended way would be to use the timer the way you did in your latest email.

2. At least in the way my email client reads your original code, your calls to the matplotlib drawing functions aren't inside the while loop and the while loop never ends...although this doesn't matter if you don't fix #1 above.

Hope that made sense.

-Dave

On 12/5/11 1:44 PM, matplotlib-users-request@lists.sourceforge.net wrote:

Message: 3
Date: Mon, 5 Dec 2011 15:46:02 +0100
From: Fabien Lafont<lafont.fabien@...287...>
Subject: Re: [Matplotlib-users] [ploting data] Live data
Cc:matplotlib-users@lists.sourceforge.net
Message-ID:
<CAC9H_cjrgQBE6e6+jzZHyfYHonTeAg0XwU7c_2G-hu=s+Z7OFQ@...1003...8...>
Content-Type: text/plain; charset=ISO-8859-1

Thx all for your remarks,

I can't understand why this code works (when I use the timer method):

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hey Fabien,

So you made your principal function run on a timer every 2 seconds? And by "lag" do you mean that the GUI is unresponsive? I'm still not seeing when the loop stops, but what you can do is set the timer at a 0 interval so it will call the principal function as fast as it can (but with no loop). The problem with this is that you have those 2 sleep calls in the function. I'm not sure why you have the sleeps, but if you need them you have two choices:

1. Make you GUI multi-threaded and you could emit a Qt signal from the data thread when the GUI thread needs to update the GUI. Yes this could get complicated, but if the sleeps are required then its probably the best way.

2. (From what I've been told, the Qt experts don't approve this) You can use app.processEvents() in your loop (after each sleep maybe) and this will pause your function and tell the main event loop to process any queued events (like GUI actions/events) which will make your GUI more responsive.

If that doesn't make sense let me know.

-Dave

···

On 12/12/11 9:16 AM, Fabien Lafont wrote:

Hi David! Sorry about the delay I was abroad and without any way to
connect to the internet.

Thank you very much. I've tried to put the principal inside the
timerEvent. It work but it lags. In fact I've set the interval of the
Timer to 2 seconds because the principal loop takes roughly 2seconds
but it's not very accurate...

Is there a way to do the principal loop, show it on the screen, then
redo the loop?

Thanks again!

Fabien

2011/12/5 David Hoese<dhoese@...287...>:

If I'm understanding your question correctly and reading your code correctly, you're asking why the timer method of doing things works, but the principal() while loop method does not.

I had a couple solutions that involved the main event loop, but I just noticed 2 main things that are probably wrong with your code:
1. You are calling 'principal' from inside __init__ so you never actually return from __init__ which means that you never call "window.show()" and therefore never call "qApp.exec_()". If you really want to use the 'principal' method you would have to connect it to a one shot timer anyway to have it run after you have started the application ('qApp.exec_()'). I think the recommended way would be to use the timer the way you did in your latest email.

2. At least in the way my email client reads your original code, your calls to the matplotlib drawing functions aren't inside the while loop and the while loop never ends...although this doesn't matter if you don't fix #1 above.

Hope that made sense.

-Dave

On 12/5/11 1:44 PM, matplotlib-users-request@lists.sourceforge.net wrote:

Message: 3
Date: Mon, 5 Dec 2011 15:46:02 +0100
From: Fabien Lafont<lafont.fabien@...287...>
Subject: Re: [Matplotlib-users] [ploting data] Live data
Cc:matplotlib-users@lists.sourceforge.net
Message-ID:
       <CAC9H_cjrgQBE6e6+jzZHyfYHonTeAg0XwU7c_2G-hu=s+Z7OFQ@...288...>
Content-Type: text/plain; charset=ISO-8859-1

Thx all for your remarks,

I can't understand why this code works (when I use the timer method):

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hey David,

I'm doing this program to control an experiment, so I want to put the
voltage on the sample, then wait two seconds to be sure there is no
current fluctuations then measure the curent with multimeters and
finally plot the datas. That's why I need the "sleep"... In fact I
wanted to use in parallel the timer to "refresh" the graph and a while
loop to "extract" the datas.

If I use startTimer(0) it works but the GUI is almost unresponsive.
I'm trying to use qApp.processEvents() but up to now I don't manage to
see the window appears...

Thanks again for your help

Fabien

2011/12/12 David Hoese <dhoese@...287...>:

···

Hey Fabien,

So you made your principal function run on a timer every 2 seconds? And by
"lag" do you mean that the GUI is unresponsive? I'm still not seeing when
the loop stops, but what you can do is set the timer at a 0 interval so it
will call the principal function as fast as it can (but with no loop). The
problem with this is that you have those 2 sleep calls in the function. I'm
not sure why you have the sleeps, but if you need them you have two choices:

1. Make you GUI multi-threaded and you could emit a Qt signal from the data
thread when the GUI thread needs to update the GUI. Yes this could get
complicated, but if the sleeps are required then its probably the best way.

2. (From what I've been told, the Qt experts don't approve this) You can use
app.processEvents() in your loop (after each sleep maybe) and this will
pause your function and tell the main event loop to process any queued
events (like GUI actions/events) which will make your GUI more responsive.

If that doesn't make sense let me know.

-Dave

On 12/12/11 9:16 AM, Fabien Lafont wrote:

Hi David! Sorry about the delay I was abroad and without any way to
connect to the internet.

Thank you very much. I've tried to put the principal inside the
timerEvent. It work but it lags. In fact I've set the interval of the
Timer to 2 seconds because the principal loop takes roughly 2seconds
but it's not very accurate...

Is there a way to do the principal loop, show it on the screen, then
redo the loop?

Thanks again!

Fabien

2011/12/5 David Hoese<dhoese@...287...>:

If I'm understanding your question correctly and reading your code
correctly, you're asking why the timer method of doing things works, but the
principal() while loop method does not.

I had a couple solutions that involved the main event loop, but I just
noticed 2 main things that are probably wrong with your code:
1. You are calling 'principal' from inside __init__ so you never actually
return from __init__ which means that you never call "window.show()" and
therefore never call "qApp.exec_()". If you really want to use the
'principal' method you would have to connect it to a one shot timer anyway
to have it run after you have started the application ('qApp.exec_()'). I
think the recommended way would be to use the timer the way you did in your
latest email.

2. At least in the way my email client reads your original code, your
calls to the matplotlib drawing functions aren't inside the while loop and
the while loop never ends...although this doesn't matter if you don't fix #1
above.

Hope that made sense.

-Dave

On 12/5/11 1:44 PM, matplotlib-users-request@lists.sourceforge.net wrote:

Message: 3
Date: Mon, 5 Dec 2011 15:46:02 +0100
From: Fabien Lafont<lafont.fabien@...287...>
Subject: Re: [Matplotlib-users] [ploting data] Live data
Cc:matplotlib-users@lists.sourceforge.net
Message-ID:

<CAC9H_cjrgQBE6e6+jzZHyfYHonTeAg0XwU7c_2G-hu=s+Z7OFQ@...288...>
Content-Type: text/plain; charset=ISO-8859-1

Thx all for your remarks,

I can't understand why this code works (when I use the timer method):

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Fabien,

The GUI not being responsive might be my fault, I've never used a timer of 0 and processEvents(). I think what might be happening is that when
you call processEvents, the timer of 0 calls your principal function again, which calls processEvents again, and so on. Try a timer of 2 again, that "should" stop the timer from being constantly triggered. Later today, once I get to work, I'll run some tests of my own and figure out if that's really the problem. Email me if you make any progress.

-Dave

···

On 12/13/2011 2:30 AM, Fabien Lafont wrote:

Hey David,

I'm doing this program to control an experiment, so I want to put the
voltage on the sample, then wait two seconds to be sure there is no
current fluctuations then measure the curent with multimeters and
finally plot the datas. That's why I need the "sleep"... In fact I
wanted to use in parallel the timer to "refresh" the graph and a while
loop to "extract" the datas.

If I use startTimer(0) it works but the GUI is almost unresponsive.
I'm trying to use qApp.processEvents() but up to now I don't manage to
see the window appears...

Thanks again for your help

Fabien

2011/12/12 David Hoese<dhoese@...287...>:

Hey Fabien,

So you made your principal function run on a timer every 2 seconds? And by
"lag" do you mean that the GUI is unresponsive? I'm still not seeing when
the loop stops, but what you can do is set the timer at a 0 interval so it
will call the principal function as fast as it can (but with no loop). The
problem with this is that you have those 2 sleep calls in the function. I'm
not sure why you have the sleeps, but if you need them you have two choices:

1. Make you GUI multi-threaded and you could emit a Qt signal from the data
thread when the GUI thread needs to update the GUI. Yes this could get
complicated, but if the sleeps are required then its probably the best way.

2. (From what I've been told, the Qt experts don't approve this) You can use
app.processEvents() in your loop (after each sleep maybe) and this will
pause your function and tell the main event loop to process any queued
events (like GUI actions/events) which will make your GUI more responsive.

If that doesn't make sense let me know.

-Dave

On 12/12/11 9:16 AM, Fabien Lafont wrote:

Hi David! Sorry about the delay I was abroad and without any way to
connect to the internet.

Thank you very much. I've tried to put the principal inside the
timerEvent. It work but it lags. In fact I've set the interval of the
Timer to 2 seconds because the principal loop takes roughly 2seconds
but it's not very accurate...

Is there a way to do the principal loop, show it on the screen, then
redo the loop?

Thanks again!

Fabien

2011/12/5 David Hoese<dhoese@...287...>:

If I'm understanding your question correctly and reading your code
correctly, you're asking why the timer method of doing things works, but the
principal() while loop method does not.

I had a couple solutions that involved the main event loop, but I just
noticed 2 main things that are probably wrong with your code:
1. You are calling 'principal' from inside __init__ so you never actually
return from __init__ which means that you never call "window.show()" and
therefore never call "qApp.exec_()". If you really want to use the
'principal' method you would have to connect it to a one shot timer anyway
to have it run after you have started the application ('qApp.exec_()'). I
think the recommended way would be to use the timer the way you did in your
latest email.

2. At least in the way my email client reads your original code, your
calls to the matplotlib drawing functions aren't inside the while loop and
the while loop never ends...although this doesn't matter if you don't fix #1
above.

Hope that made sense.

-Dave

On 12/5/11 1:44 PM, matplotlib-users-request@lists.sourceforge.net wrote:

Message: 3
Date: Mon, 5 Dec 2011 15:46:02 +0100
From: Fabien Lafont<lafont.fabien@...287...>
Subject: Re: [Matplotlib-users] [ploting data] Live data
Cc:matplotlib-users@lists.sourceforge.net
Message-ID:

<CAC9H_cjrgQBE6e6+jzZHyfYHonTeAg0XwU7c_2G-hu=s+Z7OFQ@...288...>
Content-Type: text/plain; charset=ISO-8859-1

Thx all for your remarks,

I can't understand why this code works (when I use the timer method):

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Perhaps I'm missing something, but why not use QTimer? You can't really every call sleep in a single threaded gui (for reasons you've encountered). If you need to poll something, create a QTimer for 2 seconds and have it call a measurement function to update the data. You shouldn't need any processEvents calls or sleep.

···

________________________________________
From: Fabien Lafont [lafont.fabien@...287...]
Sent: Tuesday, December 13, 2011 12:30 AM
To: David Hoese
Cc: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] [ploting data] Live data

Hey David,

I'm doing this program to control an experiment, so I want to put the
voltage on the sample, then wait two seconds to be sure there is no
current fluctuations then measure the curent with multimeters and
finally plot the datas. That's why I need the "sleep"... In fact I
wanted to use in parallel the timer to "refresh" the graph and a while
loop to "extract" the datas.

If I use startTimer(0) it works but the GUI is almost unresponsive.
I'm trying to use qApp.processEvents() but up to now I don't manage to
see the window appears...

Thanks again for your help

Fabien

2011/12/12 David Hoese <dhoese@...287...>:

Hey Fabien,

So you made your principal function run on a timer every 2 seconds? And by
"lag" do you mean that the GUI is unresponsive? I'm still not seeing when
the loop stops, but what you can do is set the timer at a 0 interval so it
will call the principal function as fast as it can (but with no loop). The
problem with this is that you have those 2 sleep calls in the function. I'm
not sure why you have the sleeps, but if you need them you have two choices:

1. Make you GUI multi-threaded and you could emit a Qt signal from the data
thread when the GUI thread needs to update the GUI. Yes this could get
complicated, but if the sleeps are required then its probably the best way.

2. (From what I've been told, the Qt experts don't approve this) You can use
app.processEvents() in your loop (after each sleep maybe) and this will
pause your function and tell the main event loop to process any queued
events (like GUI actions/events) which will make your GUI more responsive.

If that doesn't make sense let me know.

-Dave

On 12/12/11 9:16 AM, Fabien Lafont wrote:

Hi David! Sorry about the delay I was abroad and without any way to
connect to the internet.

Thank you very much. I've tried to put the principal inside the
timerEvent. It work but it lags. In fact I've set the interval of the
Timer to 2 seconds because the principal loop takes roughly 2seconds
but it's not very accurate...

Is there a way to do the principal loop, show it on the screen, then
redo the loop?

Thanks again!

Fabien

2011/12/5 David Hoese<dhoese@...287...>:

If I'm understanding your question correctly and reading your code
correctly, you're asking why the timer method of doing things works, but the
principal() while loop method does not.

I had a couple solutions that involved the main event loop, but I just
noticed 2 main things that are probably wrong with your code:
1. You are calling 'principal' from inside __init__ so you never actually
return from __init__ which means that you never call "window.show()" and
therefore never call "qApp.exec_()". If you really want to use the
'principal' method you would have to connect it to a one shot timer anyway
to have it run after you have started the application ('qApp.exec_()'). I
think the recommended way would be to use the timer the way you did in your
latest email.

2. At least in the way my email client reads your original code, your
calls to the matplotlib drawing functions aren't inside the while loop and
the while loop never ends...although this doesn't matter if you don't fix #1
above.

Hope that made sense.

-Dave

On 12/5/11 1:44 PM, matplotlib-users-request@lists.sourceforge.net wrote:

Message: 3
Date: Mon, 5 Dec 2011 15:46:02 +0100
From: Fabien Lafont<lafont.fabien@...287...>
Subject: Re: [Matplotlib-users] [ploting data] Live data
Cc:matplotlib-users@lists.sourceforge.net
Message-ID:

<CAC9H_cjrgQBE6e6+jzZHyfYHonTeAg0XwU7c_2G-hu=s+Z7OFQ@...288...>
Content-Type: text/plain; charset=ISO-8859-1

Thx all for your remarks,

I can't understand why this code works (when I use the timer method):

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

------------------------------------------------------------------------------
Systems Optimization Self Assessment
Improve efficiency and utilization of IT resources. Drive out cost and
improve service delivery. Take 5 minutes to use this Systems Optimization
Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users