[Top] [Prev] [Next]

tk

Tk -graphics toolkit

Synopsis

include "tk.m";
tk:= load Tk Tk->PATH;
Toplevel: adt
{
    id:   int;
    image: ref Draw->Image;
};
toplevel: fn(screen: ref Draw->Screen, arg: string): ref Toplevel;
namechan: fn(t: ref Toplevel, c: chan of string, n: string): string;
cmd:      fn(t: ref Toplevel, arg: string): string;
mouse:    fn(x, y, button: int);
keyboard: fn(key: int);

Description

The Tk module provides primitives for building user interfaces, based on Ousterhout's Tcl/Tk. The interface to the toolkit itself is primarily the passing of strings to and from the elements of the toolkit using the cmd function.

toplevel (screen, arg)

The toplevel function, given an existing Screen (usually one inherited from the graphics Context; see context), creates a new window, called a Toplevel, under the control of the Tk toolkit. The Toplevel is passed to the cmd and namechan functions to drive the widgets in the window. The arg parameter is a string containing creation options (such as -borderwidth 2) that are applied when creating the toplevel window.

cmd (t, arg)

The cmd function passes command strings to the widgets in the Toplevel t and returns the string resulting from their execution. For example, given a canvas .c in the Toplevel t,

	x:= int tk->cmd (t, ".c cget -actx"); 

returns the integer x coordinate of the canvas.

namechan (t, c, n)

Bindings can be created in a Toplevel that trigger strings to be sent on Limbo channels. Such channels must be declared to the Tk module using namechan. For example, to create a button that sends the word Ouch when it is pressed:

hitchannel:= chan of string;
tk->namechan(t, hitchannel, "channel");
tk->cmd(t, "button.b.Hit -text Hit -command {send channel Ouch}");
expl:= <-hitchannel;    # will see "Ouch" when button pressed

mouse ( ) and keyboard ( )

The mouse and keyboard functions deliver mouse and keyboard events to Tk, for delivery to widgets. They are usually called only by the window manager.

See Also

context, tklib, and wmlib

John K. Ousterhout, Tcl and the Tk Toolkit, Addison-Wesley Publishing Company, Reading Massachusetts, 1994.

'The Limbo/Tk Implementation,' Inferno Developer's Guide, Appendix A.

Caveat

Because Tk input is handled globally, there can be only one instance of a Tk implementation on a given machine or a given emulator.



[Top] [Prev] [Next]

infernosupport@lucent.com
Copyright © 1996,Lucent Technologies, Inc. All rights reserved.