Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions lib/matplotlib/backends/backend_nbagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import io
import os
import six
from uuid import uuid4 as uuid

from IPython.display import display, Javascript, HTML
Expand Down Expand Up @@ -64,24 +65,26 @@ def connection_info():
return '\n'.join(result)


# Note: Version 3.2 icons, not the later 4.0 ones.
# http://fontawesome.io/3.2.1/icons/
_FONT_AWESOME_CLASSES = {
'home': 'icon-home',
'back': 'icon-arrow-left',
'forward': 'icon-arrow-right',
'zoom_to_rect': 'icon-check-empty',
'move': 'icon-move',
None: None
}


class NavigationIPy(NavigationToolbar2WebAgg):
# Note: Version 3.2 icons, not the later 4.0 ones.
# http://fontawesome.io/3.2.1/icons/
_font_awesome_classes = {
'home': 'icon-home',
'back': 'icon-arrow-left',
'forward': 'icon-arrow-right',
'zoom_to_rect': 'icon-check-empty',
'move': 'icon-move',
None: None
}

# Use the standard toolbar items + download button
toolitems = [(text, tooltip_text,
_font_awesome_classes[image_file], name_of_method)
_FONT_AWESOME_CLASSES[image_file], name_of_method)
for text, tooltip_text, image_file, name_of_method
in NavigationToolbar2.toolitems
if image_file in _font_awesome_classes]
if image_file in _FONT_AWESOME_CLASSES]


class FigureManagerNbAgg(FigureManagerWebAgg):
Expand Down Expand Up @@ -191,7 +194,10 @@ def send_json(self, content):
def send_binary(self, blob):
# The comm is ascii, so we always send the image in base64
# encoded data URL form.
data_uri = "data:image/png;base64,{0}".format(b64encode(blob))
data = b64encode(blob)
if six.PY3:
data = data.decode('ascii')
data_uri = "data:image/png;base64,{0}".format(data)
self.comm.send({'data': data_uri})

def on_message(self, message):
Expand Down
24 changes: 13 additions & 11 deletions lib/matplotlib/backends/backend_webagg_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,24 +238,26 @@ def stop_event_loop(self):
backend_bases.FigureCanvasBase.stop_event_loop_default.__doc__


_JQUERY_ICON_CLASSES = {
'home': 'ui-icon ui-icon-home',
'back': 'ui-icon ui-icon-circle-arrow-w',
'forward': 'ui-icon ui-icon-circle-arrow-e',
'zoom_to_rect': 'ui-icon ui-icon-search',
'move': 'ui-icon ui-icon-arrow-4',
'download': 'ui-icon ui-icon-disk',
None: None,
}


class NavigationToolbar2WebAgg(backend_bases.NavigationToolbar2):
_jquery_icon_classes = {
'home': 'ui-icon ui-icon-home',
'back': 'ui-icon ui-icon-circle-arrow-w',
'forward': 'ui-icon ui-icon-circle-arrow-e',
'zoom_to_rect': 'ui-icon ui-icon-search',
'move': 'ui-icon ui-icon-arrow-4',
'download': 'ui-icon ui-icon-disk',
None: None,
}

# Use the standard toolbar items + download button
toolitems = [(text, tooltip_text, _jquery_icon_classes[image_file],
toolitems = [(text, tooltip_text, _JQUERY_ICON_CLASSES[image_file],
name_of_method)
for text, tooltip_text, image_file, name_of_method
in (backend_bases.NavigationToolbar2.toolitems +
(('Download', 'Download plot', 'download', 'download'),))
if image_file in _jquery_icon_classes]
if image_file in _JQUERY_ICON_CLASSES]

def _init_toolbar(self):
self.message = ''
Expand Down