-4

I'm working on a personal project that I'm going to use to spoof Discord emotes, and for the frontend I'm using Tkinter. I have the following lines of code that I'm using to cache emotes into a folder, however when using the async function to download the images, I get this error:

File "C:\Users\Usuario\AppData\Local\Programs\Python\Python313\Lib\tkinter\__init__.py", line 2774, in __init__
    self.tk.call(
    ~~~~~~~~~~~~^
        (widgetName, self._w) + extra + self._options(cnf))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: image "./img_cache/895847091056807996.png" doesn't exist

I am aware that using async would lead to the button maker not finding images sometimes, and I tried to address that with a try/except clause and a while loop, however I cannot catch the error, even though I put the exact error I'm getting in the except clause. The code for that is the following:

 async def _cache_emotes(self, emotes: list[Emote]) -> None:

    for emote in emotes:
        await emote.save_to_cache()

    local_emotes: list[Emote] = []


    while len(local_emotes) < self._buttons_per_page:

        ic(self._emotes_buttons)
        try:
            local_emotes.append(emotes.pop(0))
        except _tkinter.TclError:
            ic("Caught!")
            continue
    self._append_routine(local_emotes)

Am I missing anything?

11
  • So you just want to ignore the Error ? Commented Jan 25 at 10:08
  • No. I want it to retry to find the image, that's what the while loop is for Commented Jan 25 at 10:08
  • Have you confirmed that the error originates from the catch ? Because I highly doubt that, the code usually works. You probably have fallen into a beginners trap by not saving a reference. Commented Jan 25 at 10:54
  • I tried making the functions normal and it still gave me the error, even when all of the images had their time to download. I also did save a reference for _tkinter.TclError and it's still showing the same error. It's really strange because I gazillion checked that the path is correct and the image names match, I will try using absolute paths and report back Commented Jan 25 at 10:57
  • What you can do to store a reference: stackoverflow.com/a/45669789/13629335 Commented Jan 25 at 10:59

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.