Skip to content
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

The canvas cannot be cleared after running turtledemo clock #123370

Closed
Wulian233 opened this issue Aug 27, 2024 · 9 comments
Closed

The canvas cannot be cleared after running turtledemo clock #123370

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

Comments

@Wulian233
Copy link
Contributor

Wulian233 commented Aug 27, 2024

Bug report

Bug description:

First, run turtledemo clock. Then stop

2024-08-27 095034

When the clock stops running, the date appears, and the clear button becomes unusable. After switching to other files, the date still remains visible. Even after other files finish, pressing the clear button still cannot clear the date, but it can clear the drawings of the current file.
2024-08-27 095211

Linked PRs

@Wulian233 Wulian233 added the type-bug An unexpected behavior, bug, or error label Aug 27, 2024
@python python deleted a comment Aug 27, 2024
@python python deleted a comment from amir1387aht Aug 27, 2024
@hugovk

This comment was marked as outdated.

@hugovk

This comment was marked as outdated.

@terryjreedy
Copy link
Member

terryjreedy commented Aug 27, 2024

I'd like either the spam discussion deleted or the meat (opening post and below moved to a new issue and deleted here.
...
I am likely the current core dev with most turtledemo knowledge. Both clock and nim use (t:=Turtle()).write('text') between tracer(False) and tracer(True) after t.clear() to remove previous writes. Colormixer also uses a one-time t.write(s) without touching tracer. After a couple of experiments, I still do not know why the screen reset and clear on restarts and loads does not work. A possible next move is to minimize clock until the ghost disappears.

@Wulian233
Copy link
Contributor Author

Wulian233 commented Aug 27, 2024

I deleted my own comment, leaving hugovk's. The bug now is that drawn text will not be cleared. I tried to solve this problem, including stopIt func

self.screen.clear()
self.canvas.update()
self.canvas.delete("all") 

But all didn't work. I guess this bug has to do with write

@Wulian233
Copy link
Contributor Author

I submitted a PR yesterday, but I noticed that the turtledemo did not set the codeowner to review the request. Could Terry take a review please, Thanks!

@terryjreedy
Copy link
Member

terryjreedy commented Aug 31, 2024

I just added self as turtledemo codeowner. I'd like to see a follow-up 'modernize PR to

  1. Replace module docstring with "turtledemo/clock.py -- clock program showing time and date." File name is wrong and instruction only applies when run in turtledemo, which it is redundant.

  2. Replace German parameter names:
    distanz, winkel = distance, angle
    laenge, spitze = length, tip
    'tip' is length of side of equilateral tip triangle; would consider another pair.

Or for 1 & 2, a new issue to also modernize other files with obsolete and bloated docstrings and German names and comments. Note that tearing off Examples menu makes it easy to look through files quickly.

  1. In 'def hand', replace divisor in 'tip/2.0' with maybe 3.0 so just isosceles but not equilateral. What looks good to you?

  2. At end, remove creation and printing of 'msg' (main() call still needed though).

@Wulian233
Copy link
Contributor Author

Wulian233 commented Aug 31, 2024

  1. Replace module docstring with "turtledemo/clock.py -- clock program showing time and date." File name is wrong and instruction only applies when run in turtledemo, which it is redundant.

This problem is present in every file and can be changed in the new PR

  1. Replace German parameter names:
    distanz, winkel = distance, angle
    laenge, spitze = length, tip
    'tip' is length of side of equilateral tip triangle; would consider another pair.

I've replaced this https://github.com/python/cpython/pull/123457/files

  1. In 'def hand', replace divisor in 'tip/2.0' with maybe 3.0 so just isosceles but not equilateral. What looks good to you?
屏幕截图 2024-08-31 103752

I think it's uglier :(

Or new issue to also modernize this and other files with 1. obsolete and bloated docstrings and 2. German names and comments.

Agree

@terryjreedy
Copy link
Member

For suggestion 3, I forgot that changing the base length requires increasing the base angles and decreasing the tip angle (and changing the turns the opposite amount) so that the 2 half bases meet and the stem is still a single line.

  1. Use English local names. Since these are invisible to users, this can be done even if parameter names are left alone. Example: add distance, angle = distanz, winkel at the top of jump and modifying the rest of the body. Add stem, tip = laenge, spitze in hand and make_hand_shape. tick() has no parameters and the German local names can simply be changed.

  2. jump is called 4 times, each with 1 argument. winkel/angle always defaults to 0, making the turns no-ops. If the remaining code were inlined, I believe some of the pen up/downs would no be needed. The resulting code might be clearer.

Before closing, I will open at least 2 new issues for changes that I think can and should be backported, with justifications.

@Wulian233
Copy link
Contributor Author

Wulian233 commented Oct 17, 2024

  1. Use English local names. Since these are invisible to users, this can be done even if parameter names are left alone.

In this related PR, I ultimately decided to only fix this bug. However, on the left side of the turtledemo, users can see the code for the example case, so I don't want to add complexity and should try to keep it as simple as possible (for 5, backport should keep German names)

terryjreedy pushed a commit that referenced this issue Oct 17, 2024
…#123457)

Rewriting the day and date every tick somehow prevented them from being removed either by clicking STOP or loading another example.  The solution is to rewrite them only when they change.
terryjreedy pushed a commit to terryjreedy/cpython that referenced this issue Oct 17, 2024
…tledemo.clock (pythonGH-123457)

Rewriting the day and date every tick somehow prevented them from being removed either by clicking STOP or loading another example.  The solution is to rewrite them only when they change.
(cherry picked from commit c124577)

Co-authored-by: Wulian <xiguawulian@gmail.com>
terryjreedy added a commit that referenced this issue Oct 17, 2024
…o.clock (gh-123457) (#125653)

[3.13] gh-123370: Fix the canvas not clearing after running turtledemo.clock (GH-123457)

Rewriting the day and date every tick somehow prevented them from being removed either by clicking STOP or loading another example.  The solution is to rewrite them only when they change.
(cherry picked from commit c124577)

Co-authored-by: Wulian <xiguawulian@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 17, 2024
…tledemo.clock (pythongh-123457) (pythonGH-125653)

[3.13] pythongh-123370: Fix the canvas not clearing after running turtledemo.clock (pythonGH-123457)

Rewriting the day and date every tick somehow prevented them from being removed either by clicking STOP or loading another example.  The solution is to rewrite them only when they change.
(cherry picked from commit c124577)

(cherry picked from commit 30d7e9e)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Wulian <xiguawulian@gmail.com>
terryjreedy added a commit that referenced this issue Oct 17, 2024
…rtledemo.clock (gh-123457) (GH-125653) (#125656)

Rewriting the day and date every tick somehow prevented them from being removed either by clicking STOP or loading another example.  The solution is to rewrite them only when they change.
(cherry picked from commit c124577)

(cherry picked from commit 30d7e9e)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Wulian <xiguawulian@gmail.com>
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
Development

No branches or pull requests

4 participants