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 e4e85e6

Browse filesBrowse files
authored
Merge pull request #29781 from anntzer/fnesc
2 parents c887ecb + 90747a0 commit e4e85e6
Copy full SHA for e4e85e6

File tree

Expand file treeCollapse file tree

2 files changed

+13
-9
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-9
lines changed

‎lib/matplotlib/backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
+9-8Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,7 +2220,7 @@ def get_default_filename(self):
22202220
# Characters to be avoided in a NT path:
22212221
# https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions
22222222
# plus ' '
2223-
removed_chars = r'<>:"/\|?*\0 '
2223+
removed_chars = '<>:"/\\|?*\0 '
22242224
default_basename = default_basename.translate(
22252225
{ord(c): "_" for c in removed_chars})
22262226
default_filetype = self.get_default_filetype()
@@ -2730,23 +2730,24 @@ def resize(self, w, h):
27302730
"""For GUI backends, resize the window (in physical pixels)."""
27312731

27322732
def get_window_title(self):
2733-
"""
2734-
Return the title text of the window containing the figure, or None
2735-
if there is no window (e.g., a PS backend).
2736-
"""
2737-
return 'image'
2733+
"""Return the title text of the window containing the figure."""
2734+
return self._window_title
27382735

27392736
def set_window_title(self, title):
27402737
"""
27412738
Set the title text of the window containing the figure.
27422739
2743-
This has no effect for non-GUI (e.g., PS) backends.
2744-
27452740
Examples
27462741
--------
27472742
>>> fig = plt.figure()
27482743
>>> fig.canvas.manager.set_window_title('My figure')
27492744
"""
2745+
# This attribute is not defined in __init__ (but __init__ calls this
2746+
# setter), as derived classes (real GUI managers) will store this
2747+
# information directly on the widget; only the base (non-GUI) manager
2748+
# class needs a specific attribute for it (so that filename escaping
2749+
# can be checked in the test suite).
2750+
self._window_title = title
27502751

27512752

27522753
cursors = tools.cursors

‎lib/matplotlib/tests/test_backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_bases.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ def test_canvas_ctor():
6464

6565

6666
def test_get_default_filename():
67-
assert plt.figure().canvas.get_default_filename() == 'image.png'
67+
fig = plt.figure()
68+
assert fig.canvas.get_default_filename() == "Figure_1.png"
69+
fig.canvas.manager.set_window_title("0:1/2<3")
70+
assert fig.canvas.get_default_filename() == "0_1_2_3.png"
6871

6972

7073
def test_canvas_change():

0 commit comments

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