Skip to content

Space does not make turtledemo/sorting_animate.py Exit normally #125763

Closed

Description

@Wulian233

Bug report

Bug description:

Separate from #125691 (comment)

377852278-75a9e4fc-9313-4805-8099-39f615616ae7.mp4

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Activity

  1. rruuaanng commented on Oct 21, 2024

    @rruuaanng
    Contributor

    Can you explain it to me? I don't seem to understand it.

  2. terryjreedy commented on Oct 21, 2024

    @terryjreedy
    Member

    (Moved here from PR #125691 and revised): The normal way to stop within the demo framework is the red STOP button, and this works (but see below). The spacebar bit is for when one runs sorting_animate directly, as with f:\dev\3x>python -m turtledemo.sorting_animate. Spacebar does work then. Perhaps other demos should stop with spacebar when run directly. Maybe some do?

    The 'but' above is that both STOP and spacebar raise Terminator when pressed while the animation is going, as opposed to when waiting for input (i, etc.). Both should be fixed.

    When an example is run directly, if __name__ == "__main__": can run code limited to that mode. 'Space' as a replacement for STOP should only work when there is no STOP.

    @rruuaanng Run turtledemo either from IDLE or console (py -m turtledemo on Windows).

  3. Wulian233 commented on Oct 24, 2024

    @Wulian233
    ContributorAuthor

    Is it acceptable to remove the space-
    exit? (which is used to run individual demo directly, but other demos do not have this function)

    Or is there any other solution?

  4. terryjreedy commented on Oct 24, 2024

    @terryjreedy
    Member

    I gave the 'solution', switching on __name__, above. However, since space-exit works the same as closing the window (and this include raising Terminator), and is unique, I think we can remove it. Problems with STOP (EDIT: and window closing) are not limited to this example, and cataloging and fixing them would be another issue.

  5. Xiaokang2022 commented on Nov 8, 2024

    @Xiaokang2022
    Contributor

    @terryjreedy

    I've created a PR to fix this. PTAL.

    And about your comment:

    Problems with STOP (EDIT: and window closing) are not limited to this example, and cataloging and fixing them would be another issue.

    Do you mean that we need to create a separate issue that closing the window when a single case runtime might throw an error? (when running an animation)

    I'm not quite sure what you mean in your comment, and if that's what I said, then I'd be happy to create a new one issue and try my best to solve it.

  6. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Nov 8, 2024
  7. added a commit that references this issue on Aug 28, 2026
  8. added a commit that references this issue on Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions