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

Backport PR #29781 on branch v3.10.x (Fix escaping of nulls and "0" in default filenames.)#29784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletionslib/matplotlib/backend_bases.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2218,7 +2218,7 @@ def get_default_filename(self):
# Characters to be avoided in a NT path:
# https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions
# plus ' '
removed_chars =r'<>:"/\|?*\0 '
removed_chars = '<>:"/\\|?*\0 '
default_basename = default_basename.translate(
{ord(c): "_" for c in removed_chars})
default_filetype = self.get_default_filetype()
Expand DownExpand Up@@ -2728,23 +2728,24 @@ def resize(self, w, h):
"""For GUI backends, resize the window (in physical pixels)."""

def get_window_title(self):
"""
Return the title text of the window containing the figure, or None
if there is no window (e.g., a PS backend).
"""
return 'image'
"""Return the title text of the window containing the figure."""
return self._window_title

def set_window_title(self, title):
"""
Set the title text of the window containing the figure.

This has no effect for non-GUI (e.g., PS) backends.

Examples
--------
>>> fig = plt.figure()
>>> fig.canvas.manager.set_window_title('My figure')
"""
# This attribute is not defined in __init__ (but __init__ calls this
# setter), as derived classes (real GUI managers) will store this
# information directly on the widget; only the base (non-GUI) manager
# class needs a specific attribute for it (so that filename escaping
# can be checked in the test suite).
self._window_title = title


cursors = tools.cursors
Expand Down
5 changes: 4 additions & 1 deletionlib/matplotlib/tests/test_backend_bases.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -64,7 +64,10 @@ def test_canvas_ctor():


def test_get_default_filename():
assert plt.figure().canvas.get_default_filename() == 'image.png'
fig = plt.figure()
assert fig.canvas.get_default_filename() == "Figure_1.png"
fig.canvas.manager.set_window_title("0:1/2<3")
assert fig.canvas.get_default_filename() == "0_1_2_3.png"


def test_canvas_change():
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp