Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 76a2cd4

Browse files
committed
using class attribute for icon extension
1 parent 9e5b32e commit 76a2cd4

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

lib/matplotlib/backend_bases.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3270,24 +3270,26 @@ def _get_image_filename(self, image):
32703270
return None
32713271

32723272
basedir = os.path.join(rcParams['datapath'], 'images')
3273-
possible_images = [
3273+
possible_images = (
32743274
image,
3275-
image + self.btn_image_extension(),
3276-
os.path.join(basedir, image) + self.btn_image_extension()]
3275+
image + self._icon_extension,
3276+
os.path.join(basedir, image),
3277+
os.path.join(basedir, image) + self._icon_extension)
32773278

32783279
for fname in possible_images:
32793280
if os.path.isfile(fname):
32803281
return fname
32813282

3282-
def btn_image_extension(self):
3283+
@property
3284+
def _icon_extension(self):
32833285
"""
32843286
Get the button image format extension
32853287
32863288
Returns
32873289
=======
32883290
str: Image extension
32893291
"""
3290-
raise NotImplementedError
3292+
raise AttributeError
32913293

32923294

32933295
def trigger_tool(self, name):

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ def draw_rubberband(self, x0, y0, x1, y1):
712712

713713

714714
class ToolbarGTK3(ToolContainerBase, Gtk.Box):
715+
_icon_extension = '.png'
715716
def __init__(self, toolmanager):
716717
ToolContainerBase.__init__(self, toolmanager)
717718
Gtk.Box.__init__(self)
@@ -786,9 +787,6 @@ def _add_separator(self):
786787
self._toolarea.pack_start(sep, False, True, 0)
787788
sep.show_all()
788789

789-
def btn_image_extension(self):
790-
return '.png'
791-
792790

793791
class StatusbarGTK3(StatusbarBase, Gtk.Statusbar):
794792
def __init__(self, *args, **kwargs):

lib/matplotlib/backends/backend_tkagg.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,7 @@ def set_cursor(self, cursor):
868868

869869

870870
class ToolbarTk(ToolContainerBase, Tk.Frame):
871+
_icon_extension = '.gif'
871872
def __init__(self, toolmanager, window):
872873
ToolContainerBase.__init__(self, toolmanager)
873874
xmin, xmax = self.toolmanager.canvas.figure.bbox.intervalx
@@ -935,9 +936,6 @@ def remove_toolitem(self, name):
935936
toolitem.pack_forget()
936937
del self._toolitems[name]
937938

938-
def btn_image_extension(self):
939-
return '.gif'
940-
941939

942940
class StatusbarTk(StatusbarBase, Tk.Frame):
943941
def __init__(self, window, *args, **kwargs):

0 commit comments

Comments
 (0)