Version 3 of cursors

Updated 2001-10-12 15:12:58

http://purl.org/tcl/home/man/tcl8.4/TkCmd/cursors.htm

How would one script things to dynamically provide the user with the range of cursors available on their platform? [aka a tk_chooseCursors that works dynamically for the platform, and includes hopefully application/user defined cursors]

How would one go about defining a new cursor via Tk scripting?


SO Oct 12, 2001 - A minimalist tk script that displays the 77 cross-platform cursors in a listbox, and configures the label above the listbox to use the currently selected cursor:


 set cursors {arrow based_arrow_down based_arrow_up boat bogosity\
 bottom_left_corner bottom_right_corner bottom_side bottom_tee\
 box_spiral center_ptr circle clock coffee_mug cross cross_reverse\
 crosshair diamond_cross dot dotbox double_arrow draft_large\
 draft_small draped_box exchange fleur gobbler gumby hand1\
 hand2 heart icon iron_cross left_ptr left_side left_tee leftbutton\
 ll_angle lr_angle man middlebutton mouse pencil pirate plus\
 question_arrow right_ptr right_side right_tee rightbutton rtl_logo\
 sailboat sb_down_arrow sb_h_double_arrow sb_left_arrow\
 sb_right_arrow sb_up_arrow sb_v_double_arrow shuttle sizing\
 spider spraycan star target tcross top_left_arrow top_left_corner\
 top_right_corner top_side top_tee trek ul_angle umbrella ur_angle\
 watch X_cursor xterm}

 listbox .list -width 20 -height 10 -bg white -selectmode single -yscrollcommand ".scroll set"  
 scrollbar .scroll -command ".list yview"

 foreach index $cursors {
        .list insert end $index
        }

 frame .top
 label .top.label -textvariable current -width 20 -relief groove

 set current [.list get active]

 bind .list <ButtonRelease-1> {config}

 proc config { } {
         global current cursors
         set idx [.list curselection]
        set current [lindex $cursors $idx]
        .top.label configure -cursor $current
         return $current
  }

 pack .top
 pack .top.label
 pack .scroll -side right -fill y
 pack .list -side left -expand 1 -fill both 

 wm title . "Cursors"

Tk syntax help - Arts and crafts of Tcl-Tk programming - Category Command