@@ -117,8 +117,43 @@ def _handle_key(key):
117
117
return key
118
118
119
119
120
+ class TimerTornado (backend_bases .TimerBase ):
121
+ def __init__ (self , * args , ** kwargs ):
122
+ self ._timer = None
123
+ super ().__init__ (* args , ** kwargs )
124
+
125
+ def _timer_start (self ):
126
+ self ._timer_stop ()
127
+ if self ._single :
128
+ ioloop = tornado .ioloop .IOLoop .instance ()
129
+ self ._timer = ioloop .add_timeout (
130
+ datetime .timedelta (milliseconds = self .interval ),
131
+ self ._on_timer )
132
+ else :
133
+ self ._timer = tornado .ioloop .PeriodicCallback (
134
+ self ._on_timer ,
135
+ max (self .interval , 1e-6 ))
136
+ self ._timer .start ()
137
+
138
+ def _timer_stop (self ):
139
+ if self ._timer is None :
140
+ return
141
+ elif self ._single :
142
+ ioloop = tornado .ioloop .IOLoop .instance ()
143
+ ioloop .remove_timeout (self ._timer )
144
+ else :
145
+ self ._timer .stop ()
146
+ self ._timer = None
147
+
148
+ def _timer_set_interval (self ):
149
+ # Only stop and restart it if the timer has already been started
150
+ if self ._timer is not None :
151
+ self ._timer_stop ()
152
+ self ._timer_start ()
153
+
154
+
120
155
class FigureCanvasWebAggCore (backend_agg .FigureCanvasAgg ):
121
- supports_blit = True
156
+ _timer_cls = TimerTornado
122
157
123
158
def __init__ (self , * args , ** kwargs ):
124
159
super ().__init__ (* args , ** kwargs )
@@ -478,8 +513,7 @@ def get_javascript(cls, stream=None):
478
513
for filetype , ext in sorted (FigureCanvasWebAggCore .
479
514
get_supported_filetypes_grouped ().
480
515
items ()):
481
- if ext [0 ] != 'pgf' : # pgf does not support BytesIO
482
- extensions .append (ext [0 ])
516
+ extensions .append (ext [0 ])
483
517
output .write ("mpl.extensions = {0};\n \n " .format (
484
518
json .dumps (extensions )))
485
519
@@ -499,41 +533,6 @@ def _send_event(self, event_type, **kwargs):
499
533
s .send_json (payload )
500
534
501
535
502
- class TimerTornado (backend_bases .TimerBase ):
503
- def __init__ (self , * args , ** kwargs ):
504
- self ._timer = None
505
- super ().__init__ (* args , ** kwargs )
506
-
507
- def _timer_start (self ):
508
- self ._timer_stop ()
509
- if self ._single :
510
- ioloop = tornado .ioloop .IOLoop .instance ()
511
- self ._timer = ioloop .add_timeout (
512
- datetime .timedelta (milliseconds = self .interval ),
513
- self ._on_timer )
514
- else :
515
- self ._timer = tornado .ioloop .PeriodicCallback (
516
- self ._on_timer ,
517
- max (self .interval , 1e-6 ))
518
- self ._timer .start ()
519
-
520
- def _timer_stop (self ):
521
- if self ._timer is None :
522
- return
523
- elif self ._single :
524
- ioloop = tornado .ioloop .IOLoop .instance ()
525
- ioloop .remove_timeout (self ._timer )
526
- else :
527
- self ._timer .stop ()
528
- self ._timer = None
529
-
530
- def _timer_set_interval (self ):
531
- # Only stop and restart it if the timer has already been started
532
- if self ._timer is not None :
533
- self ._timer_stop ()
534
- self ._timer_start ()
535
-
536
-
537
536
@_Backend .export
538
537
class _BackendWebAggCoreAgg (_Backend ):
539
538
FigureCanvas = FigureCanvasWebAggCore
0 commit comments