Skip to content

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

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Wulian233 opened this issue Oct 20, 2024 · 5 comments
Open

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

Wulian233 opened this issue Oct 20, 2024 · 5 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Wulian233
Copy link
Contributor

Wulian233 commented Oct 20, 2024

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

@Wulian233 Wulian233 added the type-bug An unexpected behavior, bug, or error label Oct 20, 2024
@rruuaanng
Copy link
Contributor

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

@terryjreedy
Copy link
Member

terryjreedy commented Oct 21, 2024

(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).

@Wulian233
Copy link
Contributor Author

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?

@terryjreedy
Copy link
Member

terryjreedy commented Oct 24, 2024

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.

@Xiaokang2022
Copy link
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.

@picnixz picnixz added the stdlib Python modules in the Lib dir label Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
Status: No status
Development

No branches or pull requests

5 participants