Skip to content

default filename does not strip invalid characters on windows  #9056

Closed

Description

@1kastner

Bug report

Clicking of "save" keeps colons in window title.

Bug summary

Code for reproduction

fig = plt.figure()
fig.canvas.set_window_title("2016-06-01T13:00 start")
plt.show()

When you then click on "save", the suggested file name is 2016-06-01t13:00_start.png. I would prefer 2016-06-01t13-00_start.png or a similar string replacement which is acceptable by the operating system.

Matplotlib version

  • Operating System: Windows 10
  • Matplotlib Version: 2.0.0
  • Python Version: 3.6.0

Installed via conda.

Activity

  1. changed the title [-]fig.canvas.set_window_title(title)[/-] [+]fig.canvas.set_window_title(title) and save button do not work in harmony[/+] on Aug 18, 2017
  2. added this to the milestone on Aug 18, 2017
  3. tacaswell commented on Aug 18, 2017

    @tacaswell
    Member

    The default filename is computed in FigureCanvasBase.get_default_filename. We already relpace ' ' with '_' because spaces in filename is just a bad idea, but do not do any other validation / cleanup

    The exact work

    • add a conditional block to on windows do some extra clean up (check sys.platform)
    • add a windows-only test of this (using skipif on the test)
  4. changed the title [-]fig.canvas.set_window_title(title) and save button do not work in harmony[/-] [+]default filename does not strip invalid characters on windows [/+] on Aug 18, 2017
  5. tacaswell commented on Aug 18, 2017

    @tacaswell
    Member

    @1kastner Thanks for reporting this, the fix is pretty strait forward, but probably should be done by someone with a windows machine. Want to take a crack at it?

  6. 1kastner commented on Aug 18, 2017

    @1kastner
    Author

    I will have a look!

  7. anntzer commented on Aug 18, 2017

    @anntzer
    Contributor

    just made a PR :p

  8. 1kastner commented on Aug 18, 2017

    @1kastner
    Author

    Wow, that was quick!

  9. added
    🌱 Good first issueOpen a pull request against these issues if there are no active ones!
    on Oct 16, 2017
  10. jat255 commented on Mar 27, 2018

    @jat255

    I'll add that if the window title somehow ends up with a \n character in it, clicking the "Save figure" button will fail silently (at least in the Windows qt4 backend - see hyperspy/hyperspy#1880 and hyperspy/hyperspy#1885). IMO this needs a fix; I'm not sure why the corresponding PR #9057 was closed.

  11. francisco-dlp commented on Mar 28, 2018

    @francisco-dlp

    Is there any agreement on how to fix this?

  12. removed this from the milestone on Mar 28, 2018
  13. 5 remaining items

  14. removed
    🌱 Good first issueOpen a pull request against these issues if there are no active ones!
    on Sep 16, 2019
  15. github-actions commented on May 22, 2024

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  16. tacaswell commented on May 22, 2024

    @tacaswell
    Member

    The patch in #9057 should probably be revived.

  17. github-actions commented on May 23, 2025

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  18. added
    status: inactiveMarked by the “Stale” Github Action
    and removed
    status: inactiveMarked by the “Stale” Github Action
    on May 23, 2025
  19. QuLogic commented on May 28, 2025

    @QuLogic
    Member

    #9057 was revived as #28275 and merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions