Numerous Python TKinter operations

I have two buttons in the form, and when I click the button, it remains pressed, and the frame remains immune to the state until the operation of button 1 is finished, in my case I bring up new xterm windows that remain open, and with button2 I want to open a new xterm, but until I close the xterm window from the button1 command, the whole GUI is not responding. Why is this? Thanks, I started using TKinter 2 days ago, so it's easy on me :)

+4
source share
1 answer

Tkinter runs on a single thread. Therefore, when you press the button, the callback command does not seem to return for a long time. This will cause the Tkinter GUI to hang until the callback command returns.

If possible, the solution is to break the callback into smaller parts, possibly into a loop, and call update_idletasks () often enough to allow the Tkinter GUI to update.

If this is not possible, the callback command must create a thread so that its execution does not block the cycle of the main Tkinter event.

+4
source

Source: https://habr.com/ru/post/1386829/


All Articles