insolor / async-tkinter-loop

Asynchronous mainloop implementation for tkinter. Makes it possible to use async functions as event handlers and widget commands.
https://insolor.github.io/async-tkinter-loop/
MIT License
67 stars 3 forks source link

"invalid command name" message when closing app with protocol #119

Closed Dylgod closed 2 months ago

Dylgod commented 2 months ago

When running this code and closing the window via WM_DELETE_WINDOW:

import customtkinter as CTk
from async_tkinter_loop.mixins import AsyncCTk

class App(CTk.CTk, AsyncCTk):
    def __init__(self):
        super().__init__()
        self.geometry("200x200")
        self.protocol("WM_DELETE_WINDOW", lambda: self.destroy())

if __name__ == '__main__':
    app = App()
    app.async_mainloop()

I get back:

invalid command name "2123019874816update"
    while executing
"2123019874816update"
    ("after" script)

If I replace async_mainloop() with main_loop() it closes without a message. Async functions in my larger app work just fine but I am unable to terminate it without this message appearing. I have tried #2283 as well as destroying all widgets individually and then the app itself but no luck. I get slightly different messages depending on when the program exits. In my main app I have an async function wired to a button.

If I exit immediately on startup the message is:

invalid command name "2156938685440check_dpi_scaling"
    while executing
"2156938685440check_dpi_scaling"
    ("after" script)
invalid command name "2156936779136update"
    while executing
"2156936779136update"
    ("after" script)

Clicking the button and exiting after the async function fully executes gives me a different command name:

invalid command name "2085764248448<lambda>"
    while executing
"2085764248448<lambda>"
    ("after" script)
invalid command name "2085764248320update"
    while executing
"2085764248320update"
    ("after" script)
insolor commented 2 months ago

Duplicate of #90