Marking a Widget Busy and Unbusy

When a widget (or application) is busy doing uninterruptable work and doesn’t want to be bothered by mere mortals, the current idiom is to change the cursor shape (to a watch, a clock, or perhaps a spinning ball) as it passes over the busy widget(s). The Tk commands Busy and Unbusy automate this task for us.

$widget->Busy(?-recurse => 1,-option => value>?);

This method configures a -cursor option for $widget and, if -recurse => 1 is specified, all its descendants. If -cursor is not specified, it defaults to watch. Additional configure options are applied to $widget only. It also adds a special tag, Busy, to the bind tags of the widgets configured, such that KeyPress, KeyRelease, ButtonPress, and ButtonRelease events are ignored (with press events generating a call to bell). It then acquires a local grab for $widget.

The state of the widgets and the grab is restored by a call to:

$widget->Unbusy;

For cursor details, see Chapter 23.

Get Mastering Perl/Tk now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.