in reply to Basic questions of Tk programming
When you use Tk; the library sets up an environment which is able to wait for events. It does not start the event loop until your program hands over control, which you are supposed to do with MainLoop;
Calling sleep has the same effect: It hands over control. Tk paints the screen and ... waits. It does not get any events, though. Instead, your Initialize routine wakes up and continues, happy to use the Tk screen. The program use the Tk screen drawing capability, but not the Tk event loop.
This is an infinite loop: The call to MainLoop; never happens. You'll notice that there is an error message when you close the window:
Usage $widget->update(...) Tk::Label=HASH(0x5f5632326bd8) is not a Tk object at jmclifford.pl line 56.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Basic questions of Tk programming
by Discipulus (Canon) on Jan 24, 2025 at 09:48 UTC | |
by tybalt89 (Monsignor) on Jan 24, 2025 at 10:54 UTC | |
by Discipulus (Canon) on Jan 24, 2025 at 11:09 UTC | |
by marto (Cardinal) on Jan 24, 2025 at 11:01 UTC |