Skip to content

Commit

Permalink
BUG : fix list comprehensions over class members
Browse files Browse the repository at this point in the history
Due to scoping fixes in py3k, list comprehensions over class level
attributes during class definition does not work (see
http://stackoverflow.com/questions/13905741/accessing-class-variables-from-a-list-comprehension-in-the-class-definition).

Superficially Fixes matplotlib#3436. There seem to be other issues
  • Loading branch information
tacaswell committed Sep 3, 2014
1 parent 7794c30 commit 126fb9c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
22 changes: 11 additions & 11 deletions lib/matplotlib/backends/backend_nbagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,25 @@ def connection_info():
str(len(pylab_helpers.Gcf._activeQue)))
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)
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
20 changes: 10 additions & 10 deletions lib/matplotlib/backends/backend_webagg_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,25 +237,25 @@ def stop_event_loop(self):
stop_event_loop.__doc__ = \
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],
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

0 comments on commit 126fb9c

Please sign in to comment.