Re: Setting cursor for application

From: Erick Gallesio <>
Date: Thu, 19 Aug 1999 14:57:03 +0200 (CEST)

Sarah Calvo writes:
> I have an application with lots of windows, and for an operation that
> takes a long time I would like to set the cursor for all windows to a
> "watch" temporarily.
> I can easily set the cursor for a particular widget, but can't find a
> way to set it for the entire application. I do not want to run through
> all widgets in the program and store the old cursor value, and then set
> the cursor to the watch.

Why not?
After all this is quite easy:

    (define start-wait #f)
    (define stop-wait #f)

    (let ((cursors '()))
      (set! start-wait (lambda (cursor)
                         (for-each-widget (lambda (x)
                                            (set! cursors
                                                  (cons (cons x (tk-get x :cursor))
                                            (tk-set! x :cursor cursor)))))
      (set! stop-wait (lambda ()
                        (for-each (lambda (x)
                                    (tk-set! (car x) :cursor (cdr x)))

with the for-each-widget defined as

    (define (for-each-widget proc)
      ;; Apply PROC to all the living widgets
      (letrec ((aux (lambda (w)
                      (for-each (lambda (x)
                                  (proc x)
                                  (if (member (winfo 'class x)
                                              '("Toplevel" "Frame"))
                                      (aux x)))
                                (winfo 'children w)))))
        (proc *root*)
        (aux *root*)))

After that you just say
      (start-wait "watch")
to set the wath cursor to all the widgets and
to restore the initial cursors.

Hope it helps

                -- Erick
Received on Thu Aug 19 1999 - 21:46:27 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST