There's more...

Note that if you click on the Start! button and place the mouse over the Help button before the scheduled method is invoked, the cursor will display as help instead of watch. This happens because if the cursor option of a widget is set, it takes precedence over the cursor defined in the parent container.

To avoid this, we can save the current cursor value and change it to watch, and restore it later. The function that performs this operation can be called recursively in the child widget by iterating over the winfo_children() list:

def perform_action(self):
self.set_watch_cursor(self)
# ...

def end_action(self):
self.restore_cursor(self)
# ...

def set_watch_cursor(self, widget):
widget._old_cursor = widget.cget("cursor")
widget.config(cursor="watch")
for w in widget.winfo_children():
self.set_watch_cursor(w)

def restore_cursor(self, widget):
widget.config(cursor=widget._old_cursor)
for w in widget.winfo_children():
self.restore_cursor(w)

In the preceding code, we added the _old_cursor property to each widget, so if you follow a similar approach, keep in mind that you cannot call restore_cursor() before set_watch_cursor().

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

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