next up previous contents index
Next: Toplevel Up: Canvas Previous: Managing graphical objects   Contents   Index

Example

The function canvastest demonstrates the basic canvas usage:

(defun canvastest()
  (with-ltk ()
   (let* ((sc (make-instance 'scrolled-canvas))
          (c (canvas sc))
          (line (create-line c  (list 100 100 400 50 700 150)))
          (polygon (create-polygon c (list 50 150  250 160 250 
                                                 300 50 330 )))
          (text (create-text c 260 250 "Canvas test")))
     (pack sc :expand 1 :fill :both)
     (scrollregion c 0 0 800 800)
     )))
Figure 3: The window created by canvastest
Image canvastest

Methods:

(append-text text txt [tag])

Appends txt to the widgets content. If given, tag is the tag to be associated with the appended text.

(clear-text text)

Clear the content of the widget.

(text text)

Get the content of the widget.

(setf (text text) content)

Set the content of the widget.

(see text pos)

Ensure that pos is within the displayed area.

(tag-configure text tag option value)

Configure a tag of the text widget.

(tag-bind text tag event fun)

Bind event to the specified tag of the widget, calling fun when the event occurs.

(save-text text filename)

Write the content of the widget to the file named by filename. Note: filename is a string to be interpreted by tcl/tk on the client computer.

(load-text text filename)

Loads the content of the widget from the file named by filename. Note: filename is a string to be interpreted by tcl/tk on the client computer.


next up previous contents index
Next: Toplevel Up: Canvas Previous: Managing graphical objects   Contents   Index
Peter Herth 2006-01-29