[ltk-user] resizing canvas, exiting main loop, fullscreen
Tamas K Papp
tkpapp at gmail.com
Fri Apr 27 11:53:38 UTC 2012
I am trying to write a small program that would do the following:
1. create a full screen window with no decorations
2. when the left mouse button is pressed, change the color of the window
according to the relative position (ie the color is calculated from the
3. when the right mouse button is pressed, exit.
BTW, the application is for testing LCD screens.
I came up with the following:
(defun hex-color (r g b)
"Return a hexadecimal color string. R G B should be in [0,1]."
(flet ((normalize (x)
(assert (<= 0 x 1))
(round (* x 255))))
(format nil "#~2,0x~2,0x~2,0x"
(defun lcd-test ()
(let* ((canvas (make-instance 'canvas))
(flet ((set-color (x-rel y-rel)
(configure canvas "background"
(hex-color x-rel y-rel 0.5))))
(bind canvas "<ButtonPress-1>"
(set-color (/ (event-x evt) (window-width canvas))
(/ (event-y evt) (window-height canvas)))
(setf down t)))
(bind canvas "<ButtonPress-2>"
(declare (ignore evt))
(setf *exit-mainloop* t)))))))
a. the application does not exit (maybe I am doing it wrong, I found
*exit-mainloop* in some examples),
b. I could not figure out how to make a full screen window,
c. when the window is resized, the canvas isn't (but of course with a
fullscreen window this would not be an issue).
Any help would be appreciated.
More information about the ltk-user