Version 5 of cursor

Updated 2005-06-17 22:01:53

Documentation for this package can be found at http://tcllib.sourceforge.net/doc/cursor.html


The cursor package is intended to display all available cursors on the specific platform.


LV Anyone know a way to create multi-colored and/or animated, cursors?

PT 17-Jun-2005: On Windows you can load system cursors for use as the Tk cursor for a given window. Windows supports the use of animated cursors by using .ani files. On WindowsXP the following will load an animated cursor (the arrow's tail wags):

 package require Tk
 . configure -cursor @c:/windows/Cursors/wagtail.ani

MG After looking at the wagtail cursor, and realising Windows had a load of animated cursors in there I hadn't been away of, I wrote a quick-and-dirty script for browsing through them, which I'll share here in case anyone else wants it.

 package require Tk
 set pattern *.ani ;# animated cursors only
 #set pattern *.cur ;# only non-animated cursors
 #set pattern {{*.cur,*.ani}} ;# all cursors
 set list [glob -dir c:/windows/cursors $pattern]
 set x -1
 bind all <Button-1> advance
 bind all <Button-3> advanceBack
 pack [label .l -text "Click to start!"] -side bottom
 pack [frame .f -height 150 -width 150] -side top
 proc advance {} {
   global list x
   incr x
   if { [llength $list] == $x } {
        set x 0
      }
   foreach w [list . .f .l] {
       $w config -cursor @[lindex $list $x]
      }
   .l config -text "[lindex $list $x]\n[expr {$x+1}] of [llength $list]"
 };# advance

 proc advanceBack {} {
   global x
   if { $x >= "0" } {
        incr x -1
      }

   foreach w [list . .l .f] {
        $w config -cursor {}
      }
   .l config -text "Click to resume..."
 };# advanceBack

Just click to more forwards one (or go back to the start, if you're at the end), and right-click to "pause", and return to the default cursor, {}. (Right-clicking multiple times will backtrack through them, though it won't tell you it's doing so, and won't return to the end, when you go further back than the start.)


See also cursors


[ Category Package | Category GUI, a part of Tklib ]