Initial commit of newLISP.
[newlisp.git] / examples / tcltk.lsp
blobfc6fc4e00fde11dc89b473e100ffd5f14e4afd73
1 #!/usr/bin/newlisp
3 ; This demo shows how to write Tcl/Tk GUIs
4 ; controlled from newLISP
6 ; newlisp-tk is not required, only newlisp
7 ; and a Tcl/Tk installation
10 ; setup communications
12 (map set '(myin tcout) (pipe))
13 (map set '(tcin myout) (pipe))
14 (println "wait ...")
15 (process "/usr/bin/wish" tcin tcout)
17 ; make GUI
19 (write-buffer myout
20 [text]
21 wm geometry . 250x90
22 wm title . "Tcl/Tk and newLISP"
24 button .one -text {red}
25 button .two -text {green}
26 button .three -text {blue}
27 label .colorlabel -width 25
29 grid .one .two .three -padx 8 -row 0
30 grid .colorlabel -column 0 -columnspan 3 -pady 6
32 .one config -command {puts {(call-back "red")}}
33 .two config -command {puts {(call-back "green")}}
34 .three config -command {puts {(call-back "blue")}}
36 bind . <Destroy> {puts {(exit)}}
37 [/text])
39 (define (call-back color)
40 (write-line (append ".colorlabel config -background " color) myout)
44 ; run event loop
46 (while (read-line myin)
47 (eval-string (current-line)))
49 ;; eof