Keyword: |
canvas |
Description: |
The canvas widget is the most complex and the most
versatile. Basically, it is used to do things with graphics. With the
canvas widget it is even possible to make other widgets, but this is
not normally the point. The canvas widget is for making things like
lines, arcs, filled areas, and other geometric objects. The canvas
widget supports text, images, and other fancier things too. |
Example: |
#!/usr/bin/wish
bind . {destroy .}
scrollbar .sbx -command {.c xview} -orient horizontal
scrollbar .sby -command {.c yview} -orient vertical
canvas .c -scrollregion {0 0 1000 1000} \
-xscrollincrement 10 -yscrollincrement 10 \
-xscrollcommand {.sbx set} -yscrollcommand {.sby set};
pack .sbx -expand 0 -fill x -side bottom
pack .sby -expand 0 -fill y -side right
pack .c -expand 1 -fill both -side left
.c create oval {100 100 900 900} -fill tan -outline peru -width 30
|
|
Example: |
This program was designed to allow
the user to play with most of the elements of the canvas widget. It is
organized so that the user can put values on a stack and then execute
various canvas widget subcommands based on those values. Some commands
take or return to the stack, item numbers. These item numbers can be
preceeded with a # to illustrate what they are. To find an item number
of an object, click on it while holding the shift key. Item numbers
are useful for editing commands such as move, reconfigure, scale, etc.
The word "all" can be used as an item number and if you know what
you're doing, tags can be used too. The properties menus establish the
current status of the properties. Changing them has no immediate
effect. After changing properties, the next item produced will have
those properties. To change properties of an item, shift-select it to
put its number on the stack and then do a reconfigure when the
properties are the way you want them. Values for properties are read
from the stack. For example, if you put "red" on the stack and then
activate the normal fill menu item, then all subsequent objects will
normal fill red. The move command takes an item number and then an
offset vector. The scale command takes an item number, an origin
vector, and then a vector representing the x and y scale factors.
Coordinate location vectors should be entered to the stack as an x y
set like this "-10.625 12.375" but without the quotes. The values for
the properties are taken from the exact syntax required by the canvas
widget. The man page will answer specific questions. Alt-q will quit
the
program.
|
|
Official Syntax: |
http://www.scriptics.com/man/tcl8.4/TkCmd/canvas.htm |