Author(s): Montse Iglesias Urraca, http://www.clip.dia.fi.upm.es/
, The CLIP Group, Facultad de Informática, Universidad Politécnica de Madrid.
Version: 1.8 (2002/5/16, 21:20:27 CEST)
Version of last change: 1.7#123 (2001/9/2, 14:13:25 CEST)
The
tcltk
library package is a bidirectional interface to the Tcl (pronounced Tickle) language and Tk toolkit. Tcl is an interpreter scripting language with many extension packages, in particular the graphical interface toolkit Tk. The interaction between both languages is implemented as an interface between two processes, a Tcl/Tk process and a Prolog process. The approach allows programmers to program both in Tcl/Tk and Prolog.
Prolog - Tcl/Tk interface structure
The interface is made up of two parts: a Prolog part and a Tcl/Tk part. The Prolog part encodes the requests from a Prolog program and sends them to the Tcl/Tk part via a socket. The Tcl/Tk part receives from this socket and performs the actions included implied by the requests.
Prolog side of the Prolog - Tcl/Tk interface
The Prolog side receives the actions to perform in the Tcl/Tk side from the user program and sends them to the Tcl/Tk side through the socket connection. When the action is finished in the Tcl/Tk side, the result is returned to the user program, or the action fails if any problem occurs.
Tcl/Tk side of the Prolog - Tcl/Tk interface
The Tcl/Tk side waits for requests from the Prolog side, executes the Tcl/Tk code sent from the Prolog side. At the same time, the Tcl/Tk side handles the events and exceptions raised in the Tcl/Tk side, possibly passing on control to the Prolog side.
tcltk
):- use_module(library(tcltk)).
tcltk
)To use Tcl, you must create a Tcl interpreter object and send commands to it.
Usage: tclInterpreter(I)
I
is a reference to a Tcl interpreter.
A Tcl command is specified as follows:
Command --> Atom { other than [] } | Number | chars(PrologString) | write(Term) | format(Fmt,Args) | dq(Command) | br(Command) | sqb(Command) | min(Command) | ListOfCommands ListOfCommands --> [] |[Command|ListOfCommands]
where:
Atom
Number
chars(PrologString)
write(Term)
format(Term)
dq(Command)
br(Command)
sqb(Command)
min(Command)
ListOfCommands
Usage: tclCommand(C)
C
is a Tcl command.
Usage: tcl_new(-TclInterpreter)
TclInterpreter
.
-TclInterpreter
is a reference to a Tcl interpreter.
(tcltk:tclInterpreter/1
)
Usage: tcl_eval(+TclInterpreter,+Command,-Result)
Command
in the Tcl interpreter TclInterpreter
. The result will be stored as a string in Result
. If there is an error in Command an exception is raised. The error messages will be Tcl Exception: if the error is in the syntax of the tcltk code or Prolog Exception:, if the error is in the prolog term.
+TclInterpreter
is a reference to a Tcl interpreter.
(tcltk:tclInterpreter/1
)
+Command
is a Tcl command.
(tcltk:tclCommand/1
)
-Result
is a string (a list of character codes).
(basic_props:string/1
)
Usage: tcl_delete(+TclInterpreter)
TclInterpreter
, it deletes the interpreter from the system.
+TclInterpreter
is a reference to a Tcl interpreter.
(tcltk:tclInterpreter/1
)
Usage: tcl_event(+TclInterpreter,+Command,-Events)
Command
in the Tcl interpreter whose handle is provided in TclInterpreter
. Events
is a list of terms stored from Tcl by prolog_event. Blocks until there is something on the event queue
+TclInterpreter
is a reference to a Tcl interpreter.
(tcltk:tclInterpreter/1
)
+Command
is a Tcl command.
(tcltk:tclCommand/1
)
-Events
is a list.
(basic_props:list/1
)
Usage: tk_event_loop(+TclInterpreter)
execute(Goal)
, the predicate silently exits. If the execution of Goal
raises a Prolog error, the interpreter is deleted and an error message is given.
+TclInterpreter
is a reference to a Tcl interpreter.
(tcltk:tclInterpreter/1
)
Usage: tk_loop(+TclInterpreter)
+TclInterpreter
is a reference to a Tcl interpreter.
(tcltk:tclInterpreter/1
)
Usage: tk_new(+Options,-TclInterpreter)
Options
is a list of optional elements according to:
name(+ApplicationName)
ApplicationName
. It is also used for communicating between Tcl/Tk applications via the Tcl send command. Default name is an empty string.
display(+Display)
DISPLAY
environment variable.
file
file
. Commands will not be read from standard input and the execution returns back to Prolog only after all windows (and the interpreter) have been deleted.
+Options
is a list.
(basic_props:list/1
)
-TclInterpreter
is a reference to a Tcl interpreter.
(tcltk:tclInterpreter/1
)
Usage: tk_next_event(+TclInterpreter,-Event)
TclInterpreter
. Event
is the term correspondig to the head of a queue of events stored from Tcl with the prolog_event command.
+TclInterpreter
is a reference to a Tcl interpreter.
(tcltk:tclInterpreter/1
)
-Event
is a string (a list of character codes).
(basic_props:string/1
)
Go to the first, previous, next, last section, table of contents.