@@ -46,7 +46,7 @@ def mainloop(self):
46
46
WebAggApplication .initialize ()
47
47
for manager in Gcf .get_all_fig_managers ():
48
48
url = "http://127.0.0.1:{0}/{1}/" .format (
49
- WebAggApplication .port , manager .num )
49
+ WebAggApplication .port , manager .num )
50
50
if rcParams ['webagg.open_in_browser' ]:
51
51
import webbrowser
52
52
webbrowser .open (url )
@@ -191,8 +191,8 @@ def get_diff_image(self):
191
191
self ._png_buffer )
192
192
193
193
# Swap the renderer frames
194
- self ._renderer , self ._last_renderer = \
195
- self ._last_renderer , self ._renderer
194
+ self ._renderer , self ._last_renderer = (
195
+ self ._last_renderer , self ._renderer )
196
196
self ._force_full = False
197
197
self ._png_is_old = False
198
198
return self ._png_buffer .getvalue ()
@@ -208,8 +208,10 @@ def get_renderer(self):
208
208
need_new_renderer = (self ._lastKey != key )
209
209
210
210
if need_new_renderer :
211
- self ._renderer = backend_agg .RendererAgg (w , h , self .figure .dpi )
212
- self ._last_renderer = backend_agg .RendererAgg (w , h , self .figure .dpi )
211
+ self ._renderer = backend_agg .RendererAgg (
212
+ w , h , self .figure .dpi )
213
+ self ._last_renderer = backend_agg .RendererAgg (
214
+ w , h , self .figure .dpi )
213
215
self ._lastKey = key
214
216
215
217
return self ._renderer
@@ -261,11 +263,13 @@ def new_timer(self, *args, **kwargs):
261
263
def start_event_loop (self , timeout ):
262
264
backend_bases .FigureCanvasBase .start_event_loop_default (
263
265
self , timeout )
264
- start_event_loop .__doc__ = backend_bases .FigureCanvasBase .start_event_loop_default .__doc__
266
+ start_event_loop .__doc__ = \
267
+ backend_bases .FigureCanvasBase .start_event_loop_default .__doc__
265
268
266
269
def stop_event_loop (self ):
267
270
backend_bases .FigureCanvasBase .stop_event_loop_default (self )
268
- stop_event_loop .__doc__ = backend_bases .FigureCanvasBase .stop_event_loop_default .__doc__
271
+ stop_event_loop .__doc__ = \
272
+ backend_bases .FigureCanvasBase .stop_event_loop_default .__doc__
269
273
270
274
271
275
class FigureManagerWebAgg (backend_bases .FigureManagerBase ):
@@ -304,18 +308,22 @@ def resize(self, w, h):
304
308
class NavigationToolbar2WebAgg (backend_bases .NavigationToolbar2 ):
305
309
toolitems = list (backend_bases .NavigationToolbar2 .toolitems [:6 ]) + [
306
310
('Download' , 'Download plot' , 'filesave' , 'download' )
307
- ]
311
+ ]
308
312
309
313
def _init_toolbar (self ):
310
- jqueryui_icons = ['ui-icon ui-icon-home' ,
314
+ jqueryui_icons = [
315
+ 'ui-icon ui-icon-home' ,
311
316
'ui-icon ui-icon-circle-arrow-w' ,
312
- 'ui-icon ui-icon-circle-arrow-e' , None ,
317
+ 'ui-icon ui-icon-circle-arrow-e' ,
318
+ None ,
313
319
'ui-icon ui-icon-arrow-4' ,
314
320
'ui-icon ui-icon-search' ,
315
- 'ui-icon ui-icon-disk' ]
321
+ 'ui-icon ui-icon-disk'
322
+ ]
316
323
for index , item in enumerate (self .toolitems ):
317
324
if item [0 ] is not None :
318
- self .toolitems [index ]= (item [0 ],item [1 ],jqueryui_icons [index ],item [3 ])
325
+ self .toolitems [index ] = (
326
+ item [0 ], item [1 ], jqueryui_icons [index ], item [3 ])
319
327
self .message = ''
320
328
self .cursor = 0
321
329
@@ -361,7 +369,7 @@ class IndexPage(tornado.web.RequestHandler):
361
369
def get (self , fignum ):
362
370
with open (os .path .join (
363
371
os .path .dirname (__file__ ),
364
- 'web_static ' , 'index.html' )) as fd :
372
+ 'web_backend ' , 'index.html' )) as fd :
365
373
tpl = fd .read ()
366
374
367
375
fignum = int (fignum )
@@ -387,7 +395,7 @@ def get(self, fignum, format):
387
395
'jpeg' : 'image/jpeg' ,
388
396
'tif' : 'image/tiff' ,
389
397
'emf' : 'application/emf'
390
- }
398
+ }
391
399
392
400
self .set_header ('Content-Type' , mimetypes .get (format , 'binary' ))
393
401
@@ -438,25 +446,32 @@ def send_image(self):
438
446
def __init__ (self ):
439
447
super (WebAggApplication , self ).__init__ ([
440
448
# Static files for the CSS and JS
441
- (r'/static/(.*)' , tornado .web .StaticFileHandler ,
449
+ (r'/static/(.*)' ,
450
+ tornado .web .StaticFileHandler ,
442
451
{'path' :
443
- os .path .join (os .path .dirname (__file__ ), 'web_static ' )}),
452
+ os .path .join (os .path .dirname (__file__ ), 'web_backend ' )}),
444
453
# Static images for toolbar buttons
445
- (r'/images/(.*)' , tornado .web .StaticFileHandler ,
454
+ (r'/images/(.*)' ,
455
+ tornado .web .StaticFileHandler ,
446
456
{'path' :
447
457
os .path .join (os .path .dirname (__file__ ), '../mpl-data/images' )}),
448
- (r'/static/jquery/css/themes/base/(.*)' , tornado .web .StaticFileHandler ,
458
+ (r'/static/jquery/css/themes/base/(.*)' ,
459
+ tornado .web .StaticFileHandler ,
449
460
{'path' :
450
- os .path .join (os .path .dirname (__file__ ), 'web_static/jquery/css/themes/base' )}),
451
- (r'/static/jquery/css/themes/base/images/(.*)' , tornado .web .StaticFileHandler ,
461
+ os .path .join (os .path .dirname (__file__ ),
462
+ 'web_backend/jquery/css/themes/base' )}),
463
+ (r'/static/jquery/css/themes/base/images/(.*)' ,
464
+ tornado .web .StaticFileHandler ,
452
465
{'path' :
453
- os .path .join (os .path .dirname (__file__ ), 'web_static/jquery/css/themes/base/images' )}),
466
+ os .path .join (os .path .dirname (__file__ ),
467
+ 'web_backend/jquery/css/themes/base/images' )}),
454
468
(r'/static/jquery/js/(.*)' , tornado .web .StaticFileHandler ,
455
469
{'path' :
456
- os .path .join (os .path .dirname (__file__ ), 'web_static/jquery/js' )}),
470
+ os .path .join (os .path .dirname (__file__ ),
471
+ 'web_backend/jquery/js' )}),
457
472
(r'/static/css/(.*)' , tornado .web .StaticFileHandler ,
458
473
{'path' :
459
- os .path .join (os .path .dirname (__file__ ), 'web_static /css' )}),
474
+ os .path .join (os .path .dirname (__file__ ), 'web_backend /css' )}),
460
475
# An MPL favicon
461
476
(r'/favicon.ico' , self .FavIcon ),
462
477
# The page that contains all of the pieces
@@ -466,7 +481,7 @@ def __init__(self):
466
481
(r'/([0-9]+)/ws' , self .WebSocket ),
467
482
# Handles the downloading (i.e., saving) of static images
468
483
(r'/([0-9]+)/download.([a-z]+)' , self .Download )
469
- ])
484
+ ])
470
485
471
486
@classmethod
472
487
def initialize (cls ):
0 commit comments