Skip to content

Commit bc4c253

Browse files
committed
Use root.dooneevent() instead of root.update() to process events
1 parent a8ee8e2 commit bc4c253

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

async_tkinter_loop.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import _tkinter
12
import asyncio
23
import tkinter
34
from functools import wraps
@@ -13,9 +14,12 @@ async def main_loop(root: tkinter.Tk) -> None:
1314
:return: nothing
1415
"""
1516
while True:
17+
# Process all pending events
18+
while root.dooneevent(_tkinter.DONT_WAIT):
19+
pass
20+
1621
try:
1722
root.winfo_exists() # Will throw TclError if the main window is destroyed
18-
root.update()
1923
except TclError:
2024
break
2125

0 commit comments

Comments
 (0)