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


Groups > comp.lang.python > #97289 > unrolled thread

matplotlib timer

Started byDave Farrance <df@see.replyto.invalid>
First post2015-10-01 17:36 +0100
Last post2015-10-01 22:01 +0200
Articles 8 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  matplotlib timer Dave Farrance <df@see.replyto.invalid> - 2015-10-01 17:36 +0100
    Re: matplotlib timer Laura Creighton <lac@openend.se> - 2015-10-01 19:28 +0200
      Re: matplotlib timer Dave Farrance <df@see.replyto.invalid> - 2015-10-01 18:45 +0100
        Re: matplotlib timer Laura Creighton <lac@openend.se> - 2015-10-01 20:09 +0200
          Re: matplotlib timer Dave Farrance <df@see.replyto.invalid> - 2015-10-01 20:03 +0100
            Re: matplotlib timer Laura Creighton <lac@openend.se> - 2015-10-01 21:19 +0200
              Re: matplotlib timer Dave Farrance <df@see.replyto.invalid> - 2015-10-01 20:47 +0100
                Re: matplotlib timer Laura Creighton <lac@openend.se> - 2015-10-01 22:01 +0200

#97289 — matplotlib timer

FromDave Farrance <df@see.replyto.invalid>
Date2015-10-01 17:36 +0100
Subjectmatplotlib timer
Message-ID<3unq0b1qkisbudlj03q4qlu5t5ugpmo0th@4ax.com>
I'm trying to set up the basics of a timer-scheduled function in
matplotlib and I can't figure out how to stop the timer. Maybe the
stop() method is dysfunctional in Ubuntu 14.04 or maybe I'm getting the
syntax wrong.

If anybody's got matplotlib installed, can you try this code and tell me
if it stops after one tick as it should -- or does it continue printing
every second without stopping as mine does?

#!/usr/bin/env python
import matplotlib.pyplot as P
def fn():
  timer.stop()
  print("tick")
fig, ax = P.subplots()
timer = fig.canvas.new_timer(interval=1000)
timer.add_callback(fn)
timer.start()
P.show()
 

[toc] | [next] | [standalone]


#97292

FromLaura Creighton <lac@openend.se>
Date2015-10-01 19:28 +0200
Message-ID<mailman.304.1443720523.28679.python-list@python.org>
In reply to#97289
In a message of Thu, 01 Oct 2015 17:36:50 +0100, Dave Farrance writes:
>I'm trying to set up the basics of a timer-scheduled function in
>matplotlib and I can't figure out how to stop the timer. Maybe the
>stop() method is dysfunctional in Ubuntu 14.04 or maybe I'm getting the
>syntax wrong.
>
>If anybody's got matplotlib installed, can you try this code and tell me
>if it stops after one tick as it should -- or does it continue printing
>every second without stopping as mine does?
>
>#!/usr/bin/env python
>import matplotlib.pyplot as P
>def fn():
>  timer.stop()
>  print("tick")
>fig, ax = P.subplots()
>timer = fig.canvas.new_timer(interval=1000)
>timer.add_callback(fn)
>timer.start()
>P.show()
> 

debian unstable
Python 3.4.3+ (default, Jul 28 2015, 13:17:50)

mine ticks forever, too.

Laura

[toc] | [prev] | [next] | [standalone]


#97294

FromDave Farrance <df@see.replyto.invalid>
Date2015-10-01 18:45 +0100
Message-ID<kqrq0bh67c3bt3shq24g9i72hlo3krr1e8@4ax.com>
In reply to#97292
Laura Creighton <lac@openend.se> wrote:

>In a message of Thu, 01 Oct 2015 17:36:50 +0100, Dave Farrance writes:
>>I'm trying to set up the basics of a timer-scheduled function in
>>matplotlib and I can't figure out how to stop the timer. Maybe the
>>stop() method is dysfunctional in Ubuntu 14.04 or maybe I'm getting the
>>syntax wrong.
>>
>>If anybody's got matplotlib installed, can you try this code and tell me
>>if it stops after one tick as it should -- or does it continue printing
>>every second without stopping as mine does?
>>
>>#!/usr/bin/env python
>>import matplotlib.pyplot as P
>>def fn():
>>  timer.stop()
>>  print("tick")
>>fig, ax = P.subplots()
>>timer = fig.canvas.new_timer(interval=1000)
>>timer.add_callback(fn)
>>timer.start()
>>P.show()
>> 
>
>debian unstable
>Python 3.4.3+ (default, Jul 28 2015, 13:17:50)
>
>mine ticks forever, too.

Thanks. I've just figured out how to stop the timer.

replace "timer.stop()" with
timer.single_shot = True

Yet the documentation says that it's mandatory for the GUI backend base
to implement stop() but that single_shot is optional. Ho hum.

http://matplotlib.org/api/backend_bases_api.html#matplotlib.backend_bases.TimerBase

[toc] | [prev] | [next] | [standalone]


#97295

FromLaura Creighton <lac@openend.se>
Date2015-10-01 20:09 +0200
Message-ID<mailman.306.1443722962.28679.python-list@python.org>
In reply to#97294
In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes:
>Yet the documentation says that it's mandatory for the GUI backend base
>to implement stop() but that single_shot is optional. Ho hum.

report as a bug.  its a doc bug at least, but I think its a real bug,
and your code should have worked.

https://github.com/matplotlib/matplotlib/issues

Laura

[toc] | [prev] | [next] | [standalone]


#97299

FromDave Farrance <df@see.replyto.invalid>
Date2015-10-01 20:03 +0100
Message-ID<br0r0btskogeq3g9r0fh85dkqqpq3ov3s2@4ax.com>
In reply to#97295
Laura Creighton <lac@openend.se> wrote:

>In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes:
>>Yet the documentation says that it's mandatory for the GUI backend base
>>to implement stop() but that single_shot is optional. Ho hum.
>
>report as a bug.  its a doc bug at least, but I think its a real bug,
>and your code should have worked.
>
>https://github.com/matplotlib/matplotlib/issues

OK, done.

https://github.com/matplotlib/matplotlib/issues/5163

[toc] | [prev] | [next] | [standalone]


#97302

FromLaura Creighton <lac@openend.se>
Date2015-10-01 21:19 +0200
Message-ID<mailman.307.1443727170.28679.python-list@python.org>
In reply to#97299
In a message of Thu, 01 Oct 2015 20:03:26 +0100, Dave Farrance writes:
>Laura Creighton <lac@openend.se> wrote:
>
>>In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes:
>>>Yet the documentation says that it's mandatory for the GUI backend base
>>>to implement stop() but that single_shot is optional. Ho hum.
>>
>>report as a bug.  its a doc bug at least, but I think its a real bug,
>>and your code should have worked.
>>
>>https://github.com/matplotlib/matplotlib/issues
>
>OK, done.
>

Thank you.

Can you add how you got it to work, and the doc you read
that seems wrong?

Laura

[toc] | [prev] | [next] | [standalone]


#97304

FromDave Farrance <df@see.replyto.invalid>
Date2015-10-01 20:47 +0100
Message-ID<4d3r0bdalmomjk4jq4f62lbgr1hu3kgsfr@4ax.com>
In reply to#97302
Laura Creighton <lac@openend.se> wrote:

>In a message of Thu, 01 Oct 2015 20:03:26 +0100, Dave Farrance writes:
>>Laura Creighton <lac@openend.se> wrote:
>>
>>>In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes:
>>>>Yet the documentation says that it's mandatory for the GUI backend base
>>>>to implement stop() but that single_shot is optional. Ho hum.
>>>
>>>report as a bug.  its a doc bug at least, but I think its a real bug,
>>>and your code should have worked.
>>>
>>>https://github.com/matplotlib/matplotlib/issues
>>
>>OK, done.
>>
>
>Thank you.
>
>Can you add how you got it to work, and the doc you read
>that seems wrong?

OK.

[toc] | [prev] | [next] | [standalone]


#97306

FromLaura Creighton <lac@openend.se>
Date2015-10-01 22:01 +0200
Message-ID<mailman.308.1443729670.28679.python-list@python.org>
In reply to#97304
In a message of Thu, 01 Oct 2015 20:47:10 +0100, Dave Farrance writes:
>Laura Creighton <lac@openend.se> wrote:
>
>>In a message of Thu, 01 Oct 2015 20:03:26 +0100, Dave Farrance writes:
>>>Laura Creighton <lac@openend.se> wrote:
>>>
>>>>In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes:
>>>>>Yet the documentation says that it's mandatory for the GUI backend base
>>>>>to implement stop() but that single_shot is optional. Ho hum.
>>>>
>>>>report as a bug.  its a doc bug at least, but I think its a real bug,
>>>>and your code should have worked.
>>>>
>>>>https://github.com/matplotlib/matplotlib/issues
>>>
>>>OK, done.
>>>
>>
>>Thank you.
>>
>>Can you add how you got it to work, and the doc you read
>>that seems wrong?
>
>OK.

You, sir, are a champion.

Thank you again.

Laura

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web