-
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")
(let ((f (frame :parent root)))
(pack f :expand t :fill "both")
(pack (button :parent f
:text "Quit"
:command (lambda ()
(window-destroy root)))
:expand t))))
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.
Next we create a frame
, which will contain the button. It is important to put all windows inside a frame
and then display the frame
so that is fills the entire root
window. This way we get the usual theme colors for the root
window.
Finally we create a button
with text "Quit" and define a function which is called when the button is clicked with the :command
option. The button is displayed in the frame with the pack
geometry manager.
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.