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

Skip to content

Commit 4dd72b9

Browse files
committed
Deprecate some backend_gtk3 helper globals.
It is nicer to just define them at the point of use rather than ~400 lines later.
1 parent 5656d11 commit 4dd72b9

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``backend_gtk3.icon_filename`` and ``backend_gtk3.window_icon``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... are deprecated with no replacement.

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ def cursord(self):
5959
except TypeError as exc:
6060
return {}
6161

62+
icon_filename = _api.deprecated("3.6", obj_type="")(property(
63+
lambda self:
64+
"matplotlib.png" if sys.platform == "win32" else "matplotlib.svg"))
65+
window_icon = _api.deprecated("3.6", obj_type="")(property(
66+
lambda self:
67+
str(cbook._get_data_path("images", __getattr__("icon_filename")))))
68+
6269

6370
@functools.lru_cache()
6471
def _mpl_to_gtk_cursor(mpl_cursor):
@@ -307,7 +314,9 @@ def __init__(self, canvas, num):
307314
super().__init__(canvas, num)
308315

309316
self.window.set_wmclass("matplotlib", "Matplotlib")
310-
self.window.set_icon_from_file(window_icon)
317+
icon_ext = "png" if sys.platform == "win32" else "svg"
318+
self.window.set_icon_from_file(
319+
str(cbook._get_data_path(f"images/matplotlib.{icon_ext}")))
311320

312321
self.vbox = Gtk.Box()
313322
self.vbox.set_property("orientation", Gtk.Orientation.VERTICAL)
@@ -698,14 +707,6 @@ def trigger(self, *args, **kwargs):
698707
clipboard.set_image(pb)
699708

700709

701-
# Define the file to use as the GTk icon
702-
if sys.platform == 'win32':
703-
icon_filename = 'matplotlib.png'
704-
else:
705-
icon_filename = 'matplotlib.svg'
706-
window_icon = str(cbook._get_data_path('images', icon_filename))
707-
708-
709710
def error_msg_gtk(msg, parent=None):
710711
if parent is not None: # find the toplevel Gtk.Window
711712
parent = parent.get_toplevel()

0 commit comments

Comments
 (0)