man(1) Manual page archive

     TK(2)                                                       TK(2)

          Tk - graphics toolkit

          include "tk.m";
          tk := load Tk Tk->PATH;

          Tki:    type ref Draw->Image;

          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(screen: ref Draw->Screen, x, y, button: int);
          keyboard: fn(screen: ref Draw->Screen, key: int);
          windows:  fn(screen: ref Draw->Screen): list of ref Toplevel;
          intop:    fn(screen: ref Draw->Screen, x, y: int): ref Toplevel;
          imageget: fn(t: ref Toplevel, name: string): (Tki, Tki, string);
          imageput: fn(t: ref Toplevel, name: string, i: Tki, m: Tki): string;

          The Tk module provides primitives for building user inter-
          faces, 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; see
          section 9 of this manual for more information about the syn-
          tax of those strings.

          Toplevel creates a new window called a Toplevel, which is
          under the control of the Tk toolkit, on an existing screen,
          usually one inherited from the graphics Context (see draw-
          context(2)). The Toplevel is passed to cmd and namechan
          (q.v.)  to drive the widgets in the window.  Arg is a string
          containing creation options (such as -borderwidth 2) that
          are applied when creating the toplevel window.

          Cmd 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.

          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

     TK(2)                                                       TK(2)

          create a button that sends the word Ouch when it is pressed:
              hitchannel := chan of string;
              tk->namechan(t, hitchannel, "channel");
                   "button .b.Hit -text Hit -command {send channel Ouch}");
              expl := <-hitchannel;     # will see Ouch when button pressed

          Mouse and keyboard pass mouse and keyboard events to Tk, for
          delivery to widgets; they are usually called only by a win-
          dow manager.

          Windows returns a list of windows on the given screen. Intop
          returns a reference to the window under point (x,y) on the
          given screen, returning nil if none is found.

          Imageget returns copies of the image and mask of the Tk bit-
          map or Tk widget with the given name associated with
          Toplevel t; either Image could be nil.  Imageput replaces
          the image (i) and mask (m) of the Tk bitmap image name in t.
          Both functions return strings that are nil if the operation
          was successful, but contain a diagnostic on error (eg,
          invalid top level or name).


          intro(9), tkcmd(1), sh-tk(1), draw-context(2), wmlib(2),
          `An Overview of Limbo/Tk', this manual, Volume 2.

          Because Tk input is handled globally per Screen, there can
          be only one instance of a Tk implementation on a given
          machine, a restriction that will be lifted.