How it works...

The key to the snippet mentioned in the preceding section is the call to self.update_idletasks(). Thanks to this, the change to the button state is processed by Tkinter before calling time.sleep(). So, during the second that the callback is suspended, the button has the desired appearance, instead of ACTIVE, which is the state that Tkinter sets for the button before invoking the callback.

We used time.sleep() to illustrate a situation where a statement takes long enough to execute but is short enough to consider moving it to a new thread—in real-world scenarios, it would be a more complex computing operation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset