tk def button
tk def ibutton
name value image
tk def menu
tk def item
menu name value
title mesg default label ...
tk dump [
title dir pattern ...
tk layout [
is a loadable builtin for
It provides a set of primitives for customizing a
window and building fairly sophisticated graphical functions. It is currently implemented as a single command with a variety of subcommands. For the
command to work,
must have been started using
In the following descriptions, references to return values indicate strings put on a command's standard output.
Creating a Menu Bar
subcommand is used to define graphical pushbuttons and menus. The
commands are used to define pushbuttons labelled with text or graphical icons, respectively.
parameter is used to label buttons, and to layout both buttons and ibuttons.
is a command to be executed when the button is clicked, and must be quoted if it contains white space.
is the name of a bitmap file; it is looked for in
unless the name begins with
which suppresses prepending
is used to name and label menu buttons, and
specifies items within the corresponding pulldown menus. In
is a name supplied on a
is the label for this menu item, and
is a command to execute when this menu item is selected.
All the items in a menu are simple command buttons;
there is no provision for any other kind of control, or for cascading menus.
subcommand creates and makes visible a menu bar, using menus and buttons defined with
subcommands. The current components, if any, are removed first,
so layout with no parameters just removes all the current buttons and menus from the
window. The components are laid out from left to right, in the order presented in the
subcommand. A copy of the current
environment is made, and commands executed as a result of clicking buttons
or selecting menu items are executed in that environment.
For example, variables will have the values they had when the layout was done.
subcommand can be used to make a new copy of the environment for use by button
or menu actions.
Displaying Popup Widgets
subcommand pops up a window containing
and a single button to dismiss the window. The icon displayed in the window is
No value is returned by
subcommand is more complex;
is used to name the window, and multiple buttons labelled according to the
parameter(s) are provided.
is the number of the button which is the default choice. The leftmost button is numbered 0.
When the user selects one of the buttons, the dialog box is popped down and the
number of the button selected is returned.
subcommand pops up a standard Inferno file selection box.
specifies the initial directory to display, and pattern specifies which non-directory files to include in the list of files. If the Cancel button in the file dialog is clicked, no value is returned. If a file is selected and the Exit button is clicked, the full pathname of the file is returned, complete with final
if the file is a directory. Double clicking on a non-directory file in the list will likewise return that file's path. Double clicking on a directory in the list will display the contents of that directory.
subcommand pops up a small window with
as the label of a text field. Characters typed into the text field, up to but not including ENTER, are returned.
Dealing With the Selection
subcommand returns whatever is currently selected. When typing into the shell's window, nothing is selected, so nothing is returned. However, if invoked via a pushbutton and there is a selection, it is returned.
into the snarf buffer maintained by the window manager, and the
subcommand retrieves and returns the current contents of the snarf buffer. This provides a way to pass text between the shell and other applications. The Snarf and Paste buttons on the popup menu associated with mouse button two can also be used to do this.
Miscellaneous Tk Subcommands
subcommand lets you put
in the title bar of the
window. The old value is returned.
subcommand returns the contents of the
subcommand removes all text from the window.
subcommand returns the
commands needed to define the buttons and menus currently defined,
and to recreate the currently visible set of buttons and menus, or, if
has parameters, the commands needed to define the buttons and menus named by the parameters.
subcommand returns the position of the upper left corner of the
window relative to the upper left corner of the Inferno screen.