The heart of the system is the ability to create an embedded Tcl
interpreter with which the Prolog system can interact.
A Tcl interpreter is created within Prolog through a call to
which creates a new interpreter, initializes it, and returns a reference to it in the variable TclInterpreter. The reference can then be used in subsequent calls to manipulate the interpreter. More than one Tcl interpreter object can be active in the Prolog system at any one time.
To start a Tcl interpreter extended with Tk, the
predicate is called from Prolog. It has the following form:
which returns through the variable TclInterpreter a handle to the
underlying Tcl interpreter. The usual Tcl/Tk window pops up after this
call is made and it is with reference to that window that subsequent
widgets are created. As with the
tcl_new/1 predicate, many
Tcl/Tk interpreters may be created from Prolog at the same time through
The Options part of the call is a list of some (or none) of the following elements:
This allows Tk events to be handled while Prolog is waiting for terminal input; for example, while the Prolog system is waiting for input at the top-level prompt. Without this option, Tk events are not serviced while the Prolog system is waiting for terminal input. (For information on Tk events; see Event Handling).
This gives the main window a title ApplicationName.
This name is also used for communicating between Tcl/Tk applications
via the Tcl
send is not covered in this document. Please refer to the
(This is X windows specific.) Gives the name of the screen on which
to create the main window. If this is not given, then the default
display is determined by the
DISPLAY environment variable.
An example of using
| ?- tk_new([top_level_events, name('My SICStus/Tk App')], Tcl).
which creates a Tcl/Tk interpreter, returns a handle to it in the
Tcl and Tk events are serviced while Prolog is waiting
at the top-level prompt. The window that pops up will have the title
My SICStus/Tk App.
The reference to a Tcl interpreter returned by a call to
is used in the same way and in the same places as a reference returned
by a call to
tcl_new/1. They are both references to Tcl interpreters.
To remove a Tcl interpreter from the system, use the
which given a reference to a Tcl interpreter, closes down
the interpreter and removes it. The reference can be for a
plain Tcl interpreter or for a Tk enhanced one;
removes both kinds.