Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b160322

Browse filesBrowse files
authored
Merge pull request #15214 from anntzer/wxicons
Inline wx icon loading.
2 parents 95a0b65 + 01a5d0e commit b160322
Copy full SHA for b160322

File tree

Expand file treeCollapse file tree

1 file changed

+7
-17
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-17
lines changed

‎lib/matplotlib/backends/backend_wx.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_wx.py
+7-17Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,25 +1081,16 @@ def resize(self, width, height):
10811081

10821082
def _load_bitmap(filename):
10831083
"""
1084-
Load a bitmap file from the backends/images subdirectory in which the
1085-
matplotlib library is installed. The filename parameter should not
1086-
contain any path information as this is determined automatically.
1087-
1088-
Returns a wx.Bitmap object.
1084+
Load a wx.Bitmap from a file in the "images" directory of the Matplotlib
1085+
data.
10891086
"""
1090-
path = cbook._get_data_path('images', filename)
1091-
if not path.exists():
1092-
raise IOError(f"Could not find bitmap file '{path}'; dying")
1093-
return wx.Bitmap(str(path))
1087+
return wx.Bitmap(str(cbook._get_data_path('images', filename)))
10941088

10951089

10961090
def _set_frame_icon(frame):
10971091
bundle = wx.IconBundle()
10981092
for image in ('matplotlib.png', 'matplotlib_large.png'):
1099-
try:
1100-
icon = wx.Icon(_load_bitmap(image))
1101-
except IOError:
1102-
continue
1093+
icon = wx.Icon(_load_bitmap(image))
11031094
if not icon.IsOk():
11041095
return
11051096
bundle.AddIcon(icon)
@@ -1144,7 +1135,7 @@ def _init_toolbar(self):
11441135
self.wx_ids[text] = (
11451136
self.AddTool(
11461137
-1,
1147-
bitmap=_load_bitmap(image_file + ".png"),
1138+
bitmap=_load_bitmap(f"{image_file}.png"),
11481139
bmpDisabled=wx.NullBitmap,
11491140
label=text, shortHelp=text, longHelp=tooltip_text,
11501141
kind=(wx.ITEM_CHECK if text in ["Pan", "Zoom"]
@@ -1325,8 +1316,7 @@ def set_history_buttons(self):
13251316
class StatusBarWx(wx.StatusBar):
13261317
"""
13271318
A status bar is added to _FigureFrame to allow measurements and the
1328-
previously selected scroll function to be displayed as a user
1329-
convenience.
1319+
previously selected scroll function to be displayed as a user convenience.
13301320
"""
13311321

13321322
def __init__(self, parent, *args, **kwargs):
@@ -1356,7 +1346,7 @@ def add_toolitem(self, name, group, position, image_file, description,
13561346
tool = self.InsertTool(idx, -1, name, bmp, wx.NullBitmap, kind,
13571347
description or "")
13581348
else:
1359-
size = (self.GetTextExtent(name)[0]+10, -1)
1349+
size = (self.GetTextExtent(name)[0] + 10, -1)
13601350
if toggle:
13611351
control = wx.ToggleButton(self, -1, name, size=size)
13621352
else:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.