X Tutup
The Wayback Machine - https://web.archive.org/web/20230217044227/https://github.com/python/cpython/issues/93778
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

Tkinter canvas visual bug on angled text #93778

Closed
Unprex opened this issue Jun 13, 2022 · 4 comments
Closed

Tkinter canvas visual bug on angled text #93778

Unprex opened this issue Jun 13, 2022 · 4 comments
Labels
expert-tkinter type-bug An unexpected behavior, bug, or error

Comments

@Unprex
Copy link

Unprex commented Jun 13, 2022

Hello,
I came across a visual bug on the tkinter canvas when changing the length of angled text.

Minimal example:

import tkinter as tk

root = tk.Tk()
c = tk.Canvas(root, width=200, height=200)
text = "Hello World!00000000"
text_item = c.create_text(100, 100, text=text, angle=90)
c.pack()


def erase_text():
    global text
    text = text[1:]
    c.itemconfigure(text_item, text=text)
    if text:
        root.after(10, erase_text)


root.after(10, erase_text)
root.mainloop()

Result:

image

c.delete(tk.ALL) doesn't clear the canvas, but resizing the window or adding spaces at the end of the text solves the issue.
It only appends with certain characters and certain angles (numbers seem to work best and angle=0 doesn't reproduce the bug).

OS: Windows 10 Pro
Python: 3.10.4 / tkinter 8.6.12

@Unprex Unprex added the type-bug An unexpected behavior, bug, or error label Jun 13, 2022
@mrabarnett
Copy link

It shows the same problem even if you delete the item and then create a new one.

Given that the canvas is refreshed when it's resized, a workaround is to resize the canvas to its current size:

def erase_text():
    global text
    text = text[1:]
    c.itemconfigure(text_item, text=text)
    c["width"], c["height"] = c["width"], c["height"]
    if text:
        root.after(10, erase_text)

@serhiy-storchaka
Copy link
Member

Tkinter is a wrapper around the Tcl/Tk library. I do not see anything specific to the wrapper in this example. Most likely it is a bug in Tcl/Tk.

I cannot reproduce the bug on Linux. Try to call c.update() or root.update() after itemconfigure.

@mrabarnett
Copy link

@serhiy-storchaka: Tried that, didn't work. (Windows 10)

@serhiy-storchaka
Copy link
Member

In any case this is not a Python issue. File a report on the Tk bug tracker.

@serhiy-storchaka serhiy-storchaka closed this as not planned Won't fix, can't repro, duplicate, stale Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expert-tkinter type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants
X Tutup