@@ -44,11 +44,11 @@ def draw_if_interactive():
4444class Show (backend_bases .ShowBase ):
4545 def mainloop (self ):
4646 WebAggApplication .initialize ()
47-
47+
4848 url = "http://127.0.0.1:{port}{prefix}" .format (
4949 port = WebAggApplication .port ,
5050 prefix = WebAggApplication .url_prefix )
51-
51+
5252 if rcParams ['webagg.open_in_browser' ]:
5353 import webbrowser
5454 webbrowser .open (url )
@@ -199,7 +199,7 @@ def get_diff_image(self):
199199 self ._png_is_old = False
200200 return self ._png_buffer .getvalue ()
201201
202- def get_renderer (self ):
202+ def get_renderer (self , cleared = False ):
203203 # Mirrors super.get_renderer, but caches the old one
204204 # so that we can do things such as prodce a diff image
205205 # in get_diff_image
@@ -211,14 +211,14 @@ def get_renderer(self):
211211 need_new_renderer = True
212212 else :
213213 need_new_renderer = (self ._lastKey != key )
214-
214+
215215 if need_new_renderer :
216216 self ._renderer = backend_agg .RendererAgg (
217217 w , h , self .figure .dpi )
218218 self ._last_renderer = backend_agg .RendererAgg (
219219 w , h , self .figure .dpi )
220220 self ._lastKey = key
221-
221+
222222 return self ._renderer
223223
224224 def handle_event (self , event ):
@@ -323,16 +323,16 @@ class NavigationToolbar2WebAgg(backend_bases.NavigationToolbar2):
323323
324324 def _init_toolbar (self ):
325325 # Use the standard toolbar items + download button
326- toolitems = (backend_bases .NavigationToolbar2 .toolitems +
326+ toolitems = (backend_bases .NavigationToolbar2 .toolitems +
327327 (('Download' , 'Download plot' , 'download' , 'download' ),))
328-
328+
329329 NavigationToolbar2WebAgg .toolitems = \
330330 tuple (
331331 (text , tooltip_text , self ._jquery_icon_classes [image_file ],
332332 name_of_method )
333333 for text , tooltip_text , image_file , name_of_method
334334 in toolitems if image_file in self ._jquery_icon_classes )
335-
335+
336336 self .message = ''
337337 self .cursor = 0
338338
@@ -365,7 +365,7 @@ def release_zoom(self, event):
365365class WebAggApplication (tornado .web .Application ):
366366 initialized = False
367367 started = False
368-
368+
369369 _mpl_data_path = os .path .join (os .path .dirname (os .path .dirname (__file__ )),
370370 'mpl-data' )
371371 _mpl_dirs = {'mpl-data' : _mpl_data_path ,
@@ -385,15 +385,15 @@ def __init__(self, application, request, **kwargs):
385385 self .url_prefix = kwargs .pop ('url_prefix' , '' )
386386 return tornado .web .RequestHandler .__init__ (self , application ,
387387 request , ** kwargs )
388-
388+
389389 def get (self , fignum ):
390390 with open (os .path .join (WebAggApplication ._mpl_dirs ['web_backend' ],
391391 'single_figure.html' )) as fd :
392392 tpl = fd .read ()
393393
394394 fignum = int (fignum )
395395 manager = Gcf .get_fig_manager (fignum )
396-
396+
397397 ws_uri = 'ws://{req.host}{prefix}/' .format (req = self .request ,
398398 prefix = self .url_prefix )
399399 t = tornado .template .Template (tpl )
@@ -409,23 +409,23 @@ def __init__(self, application, request, **kwargs):
409409 self .url_prefix = kwargs .pop ('url_prefix' , '' )
410410 return tornado .web .RequestHandler .__init__ (self , application ,
411411 request , ** kwargs )
412-
412+
413413 def get (self ):
414414 with open (os .path .join (WebAggApplication ._mpl_dirs ['web_backend' ],
415415 'all_figures.html' )) as fd :
416416 tpl = fd .read ()
417-
417+
418418 ws_uri = 'ws://{req.host}{prefix}/' .format (req = self .request ,
419419 prefix = self .url_prefix )
420420 t = tornado .template .Template (tpl )
421-
421+
422422 self .write (t .generate (
423423 prefix = self .url_prefix ,
424424 ws_uri = ws_uri ,
425425 figures = sorted (list (Gcf .figs .items ()), key = lambda item : item [0 ]),
426- toolitems = NavigationToolbar2WebAgg .toolitems ))
427-
428-
426+ toolitems = NavigationToolbar2WebAgg .toolitems ))
427+
428+
429429 class MPLInterfaceJS (tornado .web .RequestHandler ):
430430 def get (self , fignum ):
431431 with open (os .path .join (WebAggApplication ._mpl_dirs ['web_backend' ],
@@ -507,7 +507,7 @@ def __init__(self, url_prefix=''):
507507 if url_prefix :
508508 assert url_prefix [0 ] == '/' and url_prefix [- 1 ] != '/' , \
509509 'url_prefix must start with a "/" and not end with one.'
510-
510+
511511 super (WebAggApplication , self ).__init__ ([
512512 # Static files for the CSS and JS
513513 (url_prefix + r'/_static/(.*)' ,
@@ -518,40 +518,40 @@ def __init__(self, url_prefix=''):
518518 (url_prefix + r'/_static/images/(.*)' ,
519519 tornado .web .StaticFileHandler ,
520520 {'path' : self ._mpl_dirs ['images' ]}),
521-
521+
522522 (url_prefix + r'/_static/jquery/css/themes/base/(.*)' ,
523523 tornado .web .StaticFileHandler ,
524524 {'path' : os .path .join (self ._mpl_dirs ['web_backend' ], 'jquery' ,
525525 'css' , 'themes' , 'base' )}),
526-
526+
527527 (url_prefix + r'/_static/jquery/css/themes/base/images/(.*)' ,
528528 tornado .web .StaticFileHandler ,
529529 {'path' : os .path .join (self ._mpl_dirs ['web_backend' ], 'jquery' ,
530530 'css' , 'themes' , 'base' , 'images' )}),
531-
531+
532532 (url_prefix + r'/_static/jquery/js/(.*)' , tornado .web .StaticFileHandler ,
533533 {'path' : os .path .join (self ._mpl_dirs ['web_backend' ],
534534 'jquery' , 'js' )}),
535-
535+
536536 (url_prefix + r'/_static/css/(.*)' , tornado .web .StaticFileHandler ,
537537 {'path' : os .path .join (self ._mpl_dirs ['web_backend' ], 'css' )}),
538-
538+
539539 # An MPL favicon
540540 (url_prefix + r'/favicon.ico' , self .FavIcon ),
541-
541+
542542 # The page that contains all of the pieces
543543 (url_prefix + r'/([0-9]+)' , self .SingleFigurePage ,
544544 {'url_prefix' : url_prefix }),
545-
545+
546546 (url_prefix + r'/([0-9]+)/mpl_interface.js' , self .MPLInterfaceJS ),
547-
547+
548548 # Sends images and events to the browser, and receives
549549 # events from the browser
550550 (url_prefix + r'/([0-9]+)/ws' , self .WebSocket ),
551-
551+
552552 # Handles the downloading (i.e., saving) of static images
553553 (url_prefix + r'/([0-9]+)/download.([a-z]+)' , self .Download ),
554-
554+
555555 # The page that contains all of the figures
556556 (url_prefix + r'/?' , self .AllFiguresPage ,
557557 {'url_prefix' : url_prefix }),
0 commit comments