#πŸ”’ TTKBootstrap is telling me an image (PIL) doesn't exist. Do I need to convert the type?

11 messages Β· Page 1 of 1 (latest)

plucky bobcat
#

I get the following error:

_tkinter.TclError: image "<PIL.Image.Image image mode=RGB size=625x176 at 0x17BCFDC5B80>" doesn't exist

after creating an image and trying to display it to a Canvas widget with .create_image. I set up print statements in my code that indicate that the image is being created and edited successfully. The error shows the correct dimensions for the image, too, so I'm almost certain that it's working up to that point. Do I need to convert the PIL object to a "real" image, or something?

worldly nacelleBOT
#

@plucky bobcat

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

scarlet carbon
plucky bobcat
#

Thanks a million!

#

I'm getting a weird error now

#

TypeError: str returned non-string (type Image)

#
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\XX\AppData\Local\Programs\Python\Python312\Lib\tkinter\__init__.py", line 1968, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\XX\PycharmProjects\pythonProject\GUITEST.py", line 228, in testButton
    cropCapture(selected_window, x1, y1, width, height)
  File "C:\Users\XX\PycharmProjects\pythonProject\GUITEST.py", line 224, in cropCapture
    imgdisplay.create_image(0, 0, image=tkimg)
  File "C:\Users\XX\AppData\Local\Programs\Python\Python312\Lib\tkinter\__init__.py", line 2875, in create_image
    return self._create('image', args, kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\XX\AppData\Local\Programs\Python\Python312\Lib\tkinter\__init__.py", line 2861, in _create
    return self.tk.getint(self.tk.call(
                          ^^^^^^^^^^^^^
TypeError: __str__ returned non-string (type Image)
#

I have inherited your magical powers of searching stack overflow, and I found the solution

worldly nacelleBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.