Thanks to visit codestin.com
Credit goes to github.com

Skip to content

tkinter.PhotoImage.put should accept image file content as bytes #13931

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
Akuli opened this issue May 3, 2025 · 1 comment
Open

tkinter.PhotoImage.put should accept image file content as bytes #13931

Akuli opened this issue May 3, 2025 · 1 comment
Labels
help wanted An actionable problem of low to medium complexity where a PR would be very welcome stubs: false positive Type checkers report false errors topic: tkinter tkinter-related issues

Comments

@Akuli
Copy link
Collaborator

Akuli commented May 3, 2025

At runtime, this displays the image with no errors. It should type-check without errors, but it doesn't.

import tkinter

with open("my_image.png", "rb") as file:
    data = file.read()

label = tkinter.Label()
image = tkinter.PhotoImage()
image.put(data, to=(0, 0))  # This line is a mypy error
label.config(image=image)
label.pack()
tkinter.mainloop()

Mypy error is:

asd.py:8: error: Argument 1 to "put" of "PhotoImage" has incompatible type "bytes"; expected "str | list[str] | list[list[str]] | list[tuple[str, ...]] | tuple[str, ...] | tuple[list[str], ...] | tuple[tuple[str, ...], ...]"  [arg-type]
@Akuli Akuli added help wanted An actionable problem of low to medium complexity where a PR would be very welcome stubs: false positive Type checkers report false errors topic: tkinter tkinter-related issues labels May 3, 2025
@VelikiiNehochuha
Copy link
Contributor

#13971

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted An actionable problem of low to medium complexity where a PR would be very welcome stubs: false positive Type checkers report false errors topic: tkinter tkinter-related issues
Projects
None yet
Development

No branches or pull requests

2 participants