Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commite4e85e6

Browse files
authored
Merge pull request#29781 from anntzer/fnesc
2 parentsc887ecb +90747a0 commite4e85e6

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

‎lib/matplotlib/backend_bases.py

Lines 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):"_"forcinremoved_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
defget_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+
returnself._window_title
27382735

27392736
defset_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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ def test_canvas_ctor():
6464

6565

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

6972

7073
deftest_canvas_change():

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp