Skip to content

Instantly share code, notes, and snippets.

@jasom
Created February 1, 2019 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasom/4c4bf02e60d85f2644f99ce7be5dce17 to your computer and use it in GitHub Desktop.
Save jasom/4c4bf02e60d85f2644f99ce7be5dce17 to your computer and use it in GitHub Desktop.
LTK example
(defpackage ltk-first-example
(:use "CL" "LTK"))
(in-package "LTK-FIRST-EXAMPLE")
(defun gui ()
(let ((ltk:*debug-tk* t))
(with-ltk ()
(wm-title *tk* "Feet to Meters")
(let ((c (make-instance 'frame)))
(grid c 0 0 :sticky "ne")
(grid-columnconfigure *tk* 0 :weight 1)
(grid-rowconfigure *tk* 0 :weight 1)
(let* ((c.feet (grid (make-instance 'entry :width 7)
1 2 :sticky "we" :padx 5 :pady 5))
(c.meters (grid (make-instance 'entry :state "readonly")
2 2 :sticky "we" :padx 5 :pady 5)))
(grid (make-instance 'button
:text "Calculate"
:command (lambda () (calculate c.feet c.meters)))
3 3 :sticky "w" :padx 5 :pady 5)
(grid (make-instance 'label :text "feet")
1 3 :sticky "w" :padx 5 :pady 5)
(grid (make-instance 'label :text "is equivalent to")
2 1 :sticky "w" :padx 5 :pady 5)
(grid (make-instance 'label :text "meters")
2 3 :sticky "w" :padx 5 :pady 5))))))
(defun calculate (feet-widget meter-widget)
(setf (text meter-widget) (format nil "~,2F" (* (read-from-string (text feet-widget)) 0.3048d0))))
Copy link

ghost commented Feb 8, 2020

https://gist.github.com/jasom/4c4bf02e60d85f2644f99ce7be5dce17#file-ltk-first-lisp-L9 helps a lot!

I was in trouble to change the title of the toplevel. I went to create a new toplevel with my preferred title and it spawned two windows!
It was frustating.

Thank you so much for sharing this gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment