Hi,
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 position),
3. when the right mouse button is pressed, exit.
BTW, the application is for testing LCD screens.
I came up with the following:
(in-package :cl-user) (require :ltk) (use-package :ltk)
(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" (normalize r) (normalize g) (normalize b))))
(defun lcd-test () (with-ltk () (let* ((canvas (make-instance 'canvas)) (down nil)) (flet ((set-color (x-rel y-rel) (configure canvas "background" (hex-color x-rel y-rel 0.5)))) (pack canvas) (bind canvas "<ButtonPress-1>" (lambda (evt) (set-color (/ (event-x evt) (window-width canvas)) (/ (event-y evt) (window-height canvas))) (setf down t))) (bind canvas "<ButtonPress-2>" (lambda (evt) (declare (ignore evt)) (setf *exit-mainloop* t)))))))
However,
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.
Tamas
On Fri, Apr 27, 2012 at 01:53:38PM +0200, Tamas K Papp wrote:
Hi,
Hello!
(bind canvas "<ButtonPress-2>" (lambda (evt) (declare (ignore evt)) (setf *exit-mainloop* t)))))))
However,
a. the application does not exit (maybe I am doing it wrong, I found *exit-mainloop* in some examples),
I can not help for the rest of the questions but "buttonpress-2" binds to the "wheel" button of the mouse on my system, try "<ButtonPress-3>" instead.
Bye. C.
cage cage@katamail.com writes:
On Fri, Apr 27, 2012 at 01:53:38PM +0200, Tamas K Papp wrote:
Hi,
Hello!
(bind canvas "<ButtonPress-2>" (lambda (evt) (declare (ignore evt)) (setf *exit-mainloop* t)))))))
However,
a. the application does not exit (maybe I am doing it wrong, I found *exit-mainloop* in some examples),
I can not help for the rest of the questions but "buttonpress-2" binds to the "wheel" button of the mouse on my system, try "<ButtonPress-3>" instead.
Thanks! I basically have it under control now, see: http://paste.lisp.org/display/129192
In particular, I defined set-wm-attributes to make the window full screen. I wonder if that would be a useful addition to LTK.
Currently I have the following issues:
1. I can't make the border disappear around the canvas.
2. If I go near the top/bottom of the screen, or move around too much with the mouse, the script crashes with the following message:
"The value 0 is not of type CHARACTER."
and I get a debugging window. Suggestions to resolve these would be appreciated. Also, comments on the code are welcome, I figured things out by reading the source.
But LTK is truly amazing! I wrote this application in about 30 minutes and it basically does what I want it to do.
Best,
Tamas
Tamas K Papp tkpapp@gmail.com writes:
Currently I have the following issues:
I can't make the border disappear around the canvas.
If I go near the top/bottom of the screen, or move around too much
with the mouse, the script crashes with the following message:
"The value 0 is not of type CHARACTER."
I have solved this issue, I forgot to quote the padding char in format. Here is the latest version:
http://paste.lisp.org/display/129192#1
Now I just need to get rid of the border :-)
Best,
Tamas
Hi Tamas,
glad to hear that you like LTk :)
To get rid of the border of the canvas (which only appears on windows) you need to (configure canvas :highlightthickness 0) To make a window without decorations for full-screen mode, I used (set-wm-overrideredirect window 1)
Peter
On Fri, Apr 27, 2012 at 4:42 PM, Tamas K Papp tkpapp@gmail.com wrote:
Tamas K Papp tkpapp@gmail.com writes:
Currently I have the following issues:
I can't make the border disappear around the canvas.
If I go near the top/bottom of the screen, or move around too much
with the mouse, the script crashes with the following message:
"The value 0 is not of type CHARACTER."
I have solved this issue, I forgot to quote the padding char in format. Here is the latest version:
http://paste.lisp.org/display/129192#1
Now I just need to get rid of the border :-)
Best,
Tamas
ltk-user site list ltk-user@common-lisp.net http://common-lisp.net/mailman/listinfo/ltk-user
Hi Peter,
Peter Herth herth@peter-herth.de writes:
glad to hear that you like LTk :)
Thanks for LTK! I was able to prototype my program very quickly.
To get rid of the border of the canvas (which only appears on windows) you need to (configure canvas :highlightthickness 0)
OK, that works fine.
To make a window without decorations for full-screen mode, I used (set-wm-overrideredirect window 1)
I assume that the window should be *tk*. So I tried
(set-wm-overrideredirect *tk* 1)
but it didn't do anything, I reverted to set-wm-attributes.
Should I submit a patch adding set-wm-attributes? Where is the development repository for LTK?
Best,
Tamas
On Fri, Apr 27, 2012 at 04:22:20PM +0200, Tamas K Papp wrote:
I can not help for the rest of the questions but "buttonpress-2" binds to the "wheel" button of the mouse on my system, try "<ButtonPress-3>" instead.
Thanks! I basically have it under control now, see:
You're welcome!
http://paste.lisp.org/display/129192
In particular, I defined set-wm-attributes to make the window full screen. I wonder if that would be a useful addition to LTK.
I am positive for that and I hope Peter, the author of the library will include it.
Currently I have the following issues:
- I can't make the border disappear around the canvas.
i can only see two horizontal (1px or so as height) lines on top and bottom of the screen, however I tried to replace pack method with grid:
(grid canvas 0 0 :sticky "nswe")
and the the bottom line seems to disappear.
- If I go near the top/bottom of the screen, or move around too much
with the mouse, the script crashes with the following message:
"The value 0 is not of type CHARACTER."
and I get a debugging window. Suggestions to resolve these would be appreciated. Also, comments on the code are welcome, I figured things out by reading the source.
I spent a minute or so moving the mouse (and my eyes are exploding now! I hope you will add a disclaimer for that!) and got no crash, sorry!
But LTK is truly amazing! I wrote this application in about 30 minutes and it basically does what I want it to do.
Totally agree!
Bye! C.