Canvas-compatible methods

We have tried to make the Slate a strict superset of the Tk canvas, in order that it can be dropped into existing applications and those applications then extended by using Slate's additional features. Here is an overview of the Slate methods that implement the standard canvas interface.

Methods extended to understand complex items

The following methods have been extended under complex item IDs:

addtag tag searchSpec
Add the tag tag to all items indicated by searchSpec. searchSpec can have all the same formats as for the find method.

bbox ?tagOrID? ....
Return the bounding box of all items indicated by the arguments. Each argument can either be an itemID or a tag.

bind tagOrID ?sequence? ?command?
Bind a command. With one argument, return the event sequences for which there is a binding to tagOrID. If sequence is given, return the command, if any, bound to the given tag or ID and event sequence. If command is given, bind it to the given tag or ID and event sequence.

coords tagOrID ?x0 y0 ... ?
With just the first argument, return the coordinates of the item or (or the first found item if the argument is a tag). If coordinates are given, set the item's coordinates to those values.

create type ?x0 y0 ... ? ?option value ...?
Create a new item and return its ID. If type starts with a lower-case letter, create a simple (canvas) item; if not, create a complex item. If the options include -tag with tags returned by calling gettags on a complex item, the new item will be added to that complex item.

delete ?tagOrID ...?
Delete all indicated items. Each argument can be an item ID or a tag.

dtag tagOrID ?delete?
If delete is not given, delete tag tagOrID from all items indicated by tagOrID; else delete tag delete from all items indicated by tagOrID.

find searchSpec
Return all items matching searchSpec. searchSpec can have the following forms:

gettags tagOrID
Return the tags of the given item, or a matching item if the argument is a tag.

itemcget tagOrID option
Read a configuration option of the given item, or a matching item if the first argument is a tag.

itemconfigure tagOrID ?option value ...?
Set configuration options of the given item, or a matching item if the first argument is a tag.

lower tagOrID ?belowThis?
Lower the given item, or a matching item if the first argument is a tag, to the bottom of the display list, or to just below belowThis if it is given.

raise tagOrID ?aboveThis?
Raise the given item, or a matching item if the first argument is a tag, to the top of the display list, or to just above aboveThis if it is given.

move tagOrID ?x y?
Move specified items by the given amount. The first argument can either be a tag or an id.

scale tagOrID ?xOrigin yOrigin xScale yScale?
Scale specified items by the given amount. The first argument can either be a tag or an id. Currently this does not work if the first argument is a tag.

type id
Return the type of the given item.

Other methods

The following methods are forwarded directly to the canvas and work correctly:

canvasx screenx ?gridspacing?
Convert a screen x coordinate into a canvas x coordinate

canvasy screeny ?gridspacing?
Convert a screen y coordinate into a canvas y coordinate

focus ???
Focus on an item

postscript ???
Generate a postscript representation of the canvas.

scan option ?val? ...
Scanning on an item???.

xview ???
Set the horizontal view for scrolling.

yview ???
Set the vertical view for scrolling.

The following methods are currently forwarded directly to the canvas but need to be modified at some time to understand complex item IDs:

dchars id first ?last?
Delete characters in a text item.

icursor id index
Set the insertion cursor.

index id index
Return the numerical value of a symbolic index.

insert id beforeThis string
Insert text at the insertion cursor.

select option ?id? ?index?
Manipulate the selection in a text item.

Back up
Tycho Home Page


Copyright © 1996, The Regents of the University of California. All rights reserved.
Last updated: 96/12/11, comments to: johnr@eecs.berkeley.edu