[Image of Linux]
The Personal Web Pages of Chris X. Edwards

Simplified TK Reference

--------------------------
Keyword:

cursor

Description: Most widgets allow for the mouse pointer (a.k.a. cursor) to be explicitly set with the -cursor configuration option. In X, these cursors shapes are the ones available to X (/usr/X11/lib/X11/fonts/misc/cursor.pcf.gz). Don't believe it? Try:
$ xsetroot -cursor_name gumby
Example:
#!/usr/bin/wish
#cursors.tcl
#cxe- A program to test cursor bitmaps in the Tk environment.
#cxe- Center the mouse pointer in the crosshairs.
#cxe- Space for next cursor, backspace for the previous cursor, q to quit.

set X { X_cursor 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 xterm }
#These cursors are also supported if using Windows
set Win { no starting size size_ne_sw size_ns size_nw_se size_we uparrow wait }
#These cursors are also supported if using a Mac
set Mac { text cross-hair }

#Create test space widgets
canvas .c -width 50 -height 50
.c create line 0 25 50 25 -fill gray
.c create line 25 0 25 50 -fill gray
label .l -width 20 -text "Press Space"
pack .c .l -side top
focus .c

#Bind keyboard controls 
bind .c <space> {incr n}
bind .c <BackSpace> {incr n -1}
bind . <q> {destroy .;exit}; #Provide a bail out

#Manage status
set all [llength $X]; set n 0;
while 1 {
   tkwait variable n;
   set n [expr $n % $all]; set c [lindex $X $n];
   .c configure -cursor $c; .l configure -text $c; }
Reference:
1
X_cursor
2
arrow
3
based_arrow_down
4
based_arrow_up
5
boat
6
bogosity
7
bottom_left_corner
8
bottom_right_corner
9
bottom_side
10
bottom_tee
11
box_spiral
12
center_ptr
13
circle
14
clock
15
coffee_mug
16
cross
17
cross_reverse
18
crosshair
19
diamond_cross
20
dot
21
dotbox
22
double_arrow
23
draft_large
24
draft_small
25
draped_box
26
exchange
27
fleur
28
gobbler
29
gumby
30
hand1
31
hand2
32
heart
33
icon
34
iron_cross
35
left_ptr
36
left_side
37
left_tee
38
leftbutton
39
ll_angle
40
lr_angle
41
man
42
middlebutton
43
mouse
44
pencil
45
pirate
46
plus
47
question_arrow
48
right_ptr
49
right_side
50
right_tee
51
rightbutton
52
rtl_logo
53
sailboat
54
sb_down_arrow
55
sb_h_double_arrow
56
sb_left_arrow
57
sb_right_arrow
58
sb_up_arrow
59
sb_v_double_arrow
60
shuttle
61
sizing
62
spider
63
spraycan
64
star
65
target
66
tcross
67
top_left_arrow
68
top_left_corner
69
top_right_corner
70
top_side
71
top_tee
72
trek
73
ul_angle
74
umbrella
75
ur_angle
76
watch
77
xterm
Official
Syntax:
http://www.scriptics.com/man/tcl8.4/TkCmd/cursors.htm

--------------------------
Previous Home Next
This page was created with only free, open-source, publicly licensed software.
This page was designed to be viewed with any browser on any system.
Chris X. Edwards ~ January 2004