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

Skip to content

Commit e4fbe4f

Browse files
committed
More fixes per @anntzer
1 parent 6360b7e commit e4fbe4f

File tree

5 files changed

+38
-52
lines changed

5 files changed

+38
-52
lines changed

lib/matplotlib/backends/_macos_helpers.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

lib/matplotlib/backends/backend_macosx.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
TimerBase)
99
from matplotlib.figure import Figure
1010
from matplotlib.widgets import SubplotTool
11-
from . import _macos_helpers
1211

1312

1413
########################################################################
@@ -62,7 +61,7 @@ def __init__(self, figure):
6261
width, height = self.get_width_height()
6362
_macosx.FigureCanvas.__init__(self, width, height)
6463
image = str(cbook._get_data_path('images/matplotlib.pdf'))
65-
_macos_helpers.set_mac_icon(image)
64+
_macosx.set_icon(image)
6665
self._device_scale = 1.0
6766

6867
def _set_device_scale(self, value):

lib/matplotlib/backends/backend_qt5.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,9 @@ def __init__(self, canvas, num):
542542
image = str(cbook._get_data_path('images/matplotlib.svg'))
543543
self.window.setWindowIcon(QtGui.QIcon(image))
544544
if sys.platform == "darwin":
545-
from . import _macos_helpers
546-
image = str(cbook._get_data_path('images/matplotlib.pdf'))
547-
_macos_helpers.set_mac_icon(image)
545+
from matplotlib.backends import _macosx
546+
pdf_icon = str(cbook._get_data_path('images/matplotlib.pdf'))
547+
_macosx.set_icon(pdf_icon)
548548

549549
# Give the keyboard focus to the figure instead of the
550550
# manager; StrongFocus accepts both tab and click to focus and

lib/matplotlib/tests/test__macos_helpers.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

lib/matplotlib/tests/test__macosx.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import sys
2+
import pytest
3+
from matplotlib import cbook
4+
5+
6+
class NoString:
7+
def __repr__(self):
8+
pass
9+
10+
11+
if sys.platform == "darwin":
12+
from matplotlib.backends import _macosx
13+
14+
def test_set_icon():
15+
with pytest.raises(TypeError):
16+
_macosx.set_icon()
17+
18+
with pytest.raises(TypeError):
19+
_macosx.set_icon(1)
20+
21+
with pytest.raises(TypeError):
22+
_macosx.set_icon([1, 2, 'a'])
23+
24+
with pytest.raises(TypeError):
25+
_macosx.set_icon(None)
26+
27+
with pytest.raises(TypeError):
28+
_macosx.set_icon(NoString())
29+
30+
with pytest.raises(RuntimeError):
31+
_macosx.set_icon("invalid path")
32+
33+
icon = cbook._get_data_path("images/matplotlib.pdf")
34+
_macosx.set_icon(icon)

0 commit comments

Comments
 (0)