tklib: tkquote, is_err, tkcmds, dialog, getstring, notice, mktabs, tabsctl - Tk user interface functions
tklib:= load Tklib Tklib->PATH;
init: fn(ctxt: ref Draw->Context);
tkquote: fn(s: string): string;
is_err: fn(e: string): int;
tkcmds: fn(top: ref Tk->Toplevel, cmds: array of string);
dialog: fn(p: ref Tk->Toplevel, msg: string, dflt: int,
labs: list of string): int;
getstring: fn(p: ref Tk->Toplevel, s: string): string;
notice: fn(p: ref Tk->Toplevel, msg: string);
mktabs: fn(p: ref Tk->Toplevel, book: string,
tabs: array of (string, string), dflt: int):
chan of string;
tabsctl: fn(p: ref Tk->Toplevel, book: string,
tabs: array of (string, string), curid:
int, newid: string): int;
The Tklib module builds on the Tk module to provide some common user interface functions.
The init function must be called before using any of these functions, with a ctxt argument holding the screen on which to draw.
The tkquote function returns a string that is the same as its arguments, but enclosed in curly braces and with internal curly braces escaped. The tkquote function can be used to make an arbitrary string, s, into a word suitable as an argument to a Tk function.
The is_err function can be called with a return value from tkcmd. It returns 1 if the string, e, represents an error (begins with an exclamation mark).
tkcmds (top, cmds)
The tkcmds function executes tkcmd on all strings in the argument array, cmds, using top for the first argument of Tkcmd. It does not check for error returns.
dialog (p, msg, dflt, labs)
The dialog function pops up a dialog box near the corner of the parent top level widget, p. It displays the given msg and a number of buttons, labeled with the strings in labs. The dialog box waits for the user to push a button, and then returns the index of the button pushed (the first element of labs is index 0). If the user types a newline, the dflt value is returned. The button with the dflt index is specially outlined in the dialog box.
getstring (p, s)
The getstring function pops up a dialog box near the corner of the parent top level widget, p. The box contains the msg and an entry widget. It waits for the user to type a string and a newline, and then returns the typed string without the newline.
notice (p, msg)
The notice function pops up a dialog box near the corner of the parent top level widget, p. It displays the given msg and an OK button. It waits for the user to click OK and then returns.
mktabs (p, book, tabs, dflt)
The mktabs function creates a pseudo tabbed notebook widget, book, for insertion into widget p. Once created, book can be packed like any other Tk widget. The notebook will initially display the page indexed by dflt.
Information for specific tab pages is contained in the tabs array. For each page, tabs contains the name displayed in the tab and a Tk widget name. Whenever a page is selected, its widget is packed in book and displayed.
The mktabs functions returns a Tk event channel. Messages received on this channel should be passed as the newid argument to tabsctl.
tabsctl (p, book, tabs, curid, newid)
The tabsctl function controls a tabbed notebook. The curid parameter is the index of the page currently selected in the notebook. The newid parameter is a string containing the index of the new page to be displayed. This is usually the information received by the channel returned from mktabs. The index of the newly selected page is returned.
Tk -graphics toolkit
Copyright © 1996,Lucent Technologies, Inc. All rights