[ltk-user] How is ":serve-event t" meant to be used?
edgar
edgar-rft at web.de
Wed Oct 16 16:26:30 UTC 2013
Hi all on the LTK list,
I'm trying to open a scrolled-canvas widget in the Tk main window and
then interactively drawing a line on the canvas (details in the REPL
transcripts below), but LTK is throwing nothing but errors at me.
The questions are:
1. Am I doing something fundamentally wrong in the examples below?
2. In case the errors are based on bugs in LTK, how can I help to
improve the situation?
I have some experience in both Tcl/Tk and Common Lisp. I'm a hardware
electrician and not a professional programmer, but I know how to use
diff to produce patches. But before starting to hack around in the
LTK code I would first like to hear an opinion of somebody who has
better insight than me into the LTK internals.
SBCL 1.1.12 on Debian 7.2 Wheezy (64-bit), LTK 0.98, Tcl/Tk 8.5
Here is what I'm doing:
------------------------- Start of REPL Transcript ---------------------
CL-USER> (ql:quickload :ltk)
; Loading "ltk"
(:LTK)
CL-USER> ltk:*ltk-version*
"0.98"
CL-USER> (defpackage :ltk-test (:use :cl :ltk))
#<PACKAGE "LTK-TEST">
CL-USER> (in-package :ltk-test)
#<PACKAGE "LTK-TEST">
LTK-TEST> (defparameter *canvas* nil)
*CANVAS*
LTK-TEST> (defun ltk-test ()
(with-ltk (:serve-event t)
(let ((sc (make-instance 'scrolled-canvas)))
(pack sc :expand 1 :fill :both)
(setf *canvas* (canvas sc)))))
LTK-TEST
LTK-TEST> (ltk-test)
; the Tk window appears on the screen
NIL
LTK-TEST> (create-line *canvas* '(10 10 20 20))
The value NIL is not of type STREAM.
[Condition of type TYPE-ERROR]
Backtrace:
0: (LTK::FLUSH-WISH)
1: (CREATE-LINE #<CANVAS {1004C0DC13}> (10 10 20 20))
2: (SB-INT:SIMPLE-EVAL-IN-LEXENV
(CREATE-LINE *CANVAS* (QUOTE (10 10 20 20))) #<NULL-LEXENV>)
3: (EVAL (CREATE-LINE *CANVAS* (QUOTE (10 10 20 20))))
;; Looking at the definition of FLUSH-WISH in ltk.lisp, the reason
;; for the error seems to be: (wish-stream *wish*) => NIL
LTK-TEST> *wish*
#S(LTK::LTK-CONNECTION
:STREAM NIL
:CALLBACKS #<HASH-TABLE :TEST EQUAL :COUNT 0 {1007C0E9D3}>
:AFTER-IDS #<HASH-TABLE :TEST EQUAL :COUNT 0 {1007C0EA73}>
:COUNTER 1
:AFTER-COUNTER 1
:EVENT-QUEUE NIL
:CALL-WITH-CONDITION-HANDLERS-FUNCTION
#<FUNCTION (LAMBDA # :IN MAKE-LTK-CONNECTION) {1007C0EDCB}>
:INPUT-HANDLER NIL
:REMOTEP NIL
:OUTPUT-BUFFER ("senddata [.wc.wf create line 10 10 20 20]")
:VARIABLES #<HASH-TABLE :TEST EQUAL :COUNT 0 {1007C0EE53}>)
-------------------------- End of REPL Transcript ----------------------
Here is what happens if I try to do the same thing manually:
------------------------- Start of REPL Transcript ---------------------
LTK-TEST> (start-wish)
; an empty Tk window appears on the screen
NIL
LTK-TEST> (mainloop :serve-event t)
NIL
LTK-TEST> (defparameter *scrolled-canvas* (make-instance
'scrolled-canvas)) *SCROLLED-CANVAS*
LTK-TEST> (pack *scrolled-canvas* :expand 1 :fill :both)
; the scrolled-canvas widget appears in the Tk window
#<SCROLLED-CANVAS {10040DEB83}>
LTK-TEST> (defparameter *canvas* (canvas *scrolled-canvas*))
*CANVAS*
LTK-TEST> (create-line *canvas* '(10 10 20 20))
; YIPPIE, a line appears on the canvas :-)
1
LTK-TEST> (setf *exit-mainloop* t)
; the Tk window doesn't disappear from the screen
T
LTK-TEST> (exit-wish)
attempt to THROW to a tag that does not exist:
#S(LTK::LTK-CONNECTION
:STREAM NIL
:CALLBACKS #<HASH-TABLE :TEST EQUAL :COUNT 0 {10068F9063}>
:AFTER-IDS #<HASH-TABLE :TEST EQUAL :COUNT 0 {10068F9103}>
:COUNTER 5
:AFTER-COUNTER 1
:EVENT-QUEUE NIL
:CALL-WITH-CONDITION-HANDLERS-FUNCTION #<FUNCTION FUNCALL>
:INPUT-HANDLER NIL
:REMOTEP NIL
:OUTPUT-BUFFER NIL
:VARIABLES #<HASH-TABLE
:TEST EQUAL :COUNT 0 {10068F91A3}>)
[Condition of type SB-INT:SIMPLE-CONTROL-ERROR]
Backtrace:
0: ("no debug information for frame")
1: (EXIT-WISH) [tl,external]
2: (SB-INT:SIMPLE-EVAL-IN-LEXENV (EXIT-WISH) #<NULL-LEXENV>)
3: (EVAL (EXIT-WISH))
-------------------------- End of REPL Transcript ----------------------
Looking at the definition of EXIT-WISH in ltk.lisp, the reason for
the error is the line (throw *wish* nil) but I'm not sure if the
EXIT-WISH function is meant to be called in this context at all.
The question remains:
How is ":serve-event t" meant to be used in a meaningful way?
Or am I too stupid to use LTK properly?
Thanks in advance for your answers,
- edgar
More information about the ltk-user
mailing list