Hello.
I want to use PNG-Images on Ltk-Buttons. Therefore, I want to use the Img-Package. I am not familiar with this. I read the documentation and tried the following:
(setf *init-wish-hook* (append *init-wish-hook* (list (lambda () (send-wish "package require Img")))))
(defun config-button-png (button png) (format-wish "~A configure -image [ image create photo -data "~A" ]" (ltk::name button) png))
(with-ltk () (let* ((f (make-instance 'frame)) (b (make-instance 'button :master f :text "" :command (lambda () (format t "Quak!~%")))))
(pack f) (config-button-png b "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9kEARQbItOgpzAAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAEklEQVQY02P8z4APMDGMSmMBAEEsARNlYhAzAAAAAElFTkSuQmCC") (pack b)))
This doesnt work. Also when replacing -data by -file and providing a filename, it doesnt work. I also tried to replace ltk::name by ltk::widget-path. There is no Image appearing. In the wish-shell, the following works:
package require Img set frame .frame toplevel $frame frame $frame.f button $frame.f.b -text "" $frame.f.b configure -image [ image create photo -data "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9kEARQbItOgpzAAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAEklEQVQY02P8z4APMDGMSmMBAEEsARNlYhAzAAAAAElFTkSuQmCC" ]
Do you have any clue what I am doing wrong?
Thank You. Christoph Senjak
Hi Christoph,
if you want to refer to widgets on the tk-side you usually want to pass (widget-path widget). Other than that I don't see an obvious mistake without trying it out myself (on travel atm.) But have you tried to use the ltk functions for images as make-image and image-load? Last time I tried, they worked for me. If that all does not help, set ltk:*debug-tk* to true and post the output it generates, which should allow us to see much better what goes wrong.
Peter
On Wed, Apr 1, 2009 at 11:19 PM, Christoph Senjak christoph.senjak@googlemail.com wrote:
Hello.
I want to use PNG-Images on Ltk-Buttons. Therefore, I want to use the Img-Package. I am not familiar with this. I read the documentation and tried the following:
(setf *init-wish-hook* (append *init-wish-hook* (list (lambda () (send-wish "package require Img")))))
(defun config-button-png (button png) (format-wish "~A configure -image [ image create photo -data "~A" ]" (ltk::name button) png))
(with-ltk () (let* ((f (make-instance 'frame)) (b (make-instance 'button :master f :text "" :command (lambda () (format t "Quak!~%")))))
(pack f) (config-button-png b "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9kEARQbItOgpzAAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAEklEQVQY02P8z4APMDGMSmMBAEEsARNlYhAzAAAAAElFTkSuQmCC") (pack b)))
This doesnt work. Also when replacing -data by -file and providing a filename, it doesnt work. I also tried to replace ltk::name by ltk::widget-path. There is no Image appearing. In the wish-shell, the following works:
package require Img set frame .frame toplevel $frame frame $frame.f button $frame.f.b -text "" $frame.f.b configure -image [ image create photo -data "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9kEARQbItOgpzAAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAEklEQVQY02P8z4APMDGMSmMBAEEsARNlYhAzAAAAAElFTkSuQmCC" ]
Do you have any clue what I am doing wrong?
Thank You. Christoph Senjak
ltk-user site list ltk-user@common-lisp.net http://common-lisp.net/mailman/listinfo/ltk-user
Hello.
Thanks for the fast answer.
Other than that I don't see an obvious mistake without trying it out myself (on travel atm.)
Well, for some reason, now it works. I cant say why. I tried more than two hours but I couldnt get it work, and now just tried the first time since that and it worked. Now I cannot even reproduce why it didnt work earlier. Sorry.
But have you tried to use the ltk functions for images as make-image and image-load?
Ok, I have tried it. It does work when I add the Load-Routine for the Img-Package. But with image-load, I can not use base64-encoded data, just can pass filenames. My application loads all data anyway, so I would like to prevent it from having to use external files in the resulting binary. Maybe this would be a good feature for ltk, and shouldnt be too hard to realize, as far as I see (but I dont know it, I am very new to it).
Last time I tried, they worked for me. If that all does not help, set ltk:*debug-tk* to true and post the output it generates, which should allow us to see much better what goes wrong.
Thank you.
Christoph Senjak