Created
February 1, 2019 19:49
LTK example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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