-
Notifications
You must be signed in to change notification settings - Fork 1
Home
cl-simple-tk
is a cffi
based interface between tcl/tk
and lisp
. cl-simple-tk
communicates with tcl/tk
through its library interface. After the initial setup of the gui the control goes to tcl/tk
which communicates back with lisp
through callbacks.
In the first example we show a window with a quit button.
(defpackage :tk-user
(:use :cl :tk)
(:export :main))
(in-package :tk-user)
(defun main ()
(with-tk-root (root)
(setf (window-title root) "Example 1")
(setf (window-geometry root) "300x100+100+200")
(pack (button :text "Quit"
:command (lambda ()
(window-destroy root)))
:padx 5 :pady 5)))
The with-tk-root
creates a main window for the GUI called root
. The next two forms set the title of the window and its geometry. The size of the window is 300x100 pixels and the top left corner is at the 100x200 pixel on the screen.
The last form creates a button with text "Quit" and defines a function which is called when the button is clicked. The button is placed into root
using the pack
geometry manager. Five pixels are put around the button on each side.
After the gui is set up, with-tk-root
calls the tk
event loop. When the button is clicked, the root
window is destroyed, the event loop stops and the main
function will return.