File: tcltk.lsp

package info (click to toggle)
newlisp 10.7.5-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 6,248 kB
  • sloc: ansic: 33,280; lisp: 4,181; sh: 609; makefile: 215
file content (46 lines) | stat: -rw-r--r-- 978 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env newlisp
;
; demo how to write Tcl/Tk GUIs controlled from newLISP
;
;  a Tcl/Tk installation is required
;  the example has been tested on Mac OS X and Unix
;

; setup communications
(map set '(myin tcout) (pipe))
(map set '(tcin myout) (pipe))
(println "wait ...")
(process "/usr/bin/wish" tcin tcout)

; make GUI
(write-buffer myout 
[text]
wm geometry . 250x90
wm title . "Tcl/Tk and newLISP"

button .one -text {red}
button .two -text {green}
button .three -text {blue}
label .colorlabel -width 25

grid .one .two .three -padx 8 -row 0
grid .colorlabel -column 0 -columnspan 3 -pady 6

.one config -command {puts {(call-back "red")}}
.two config -command {puts {(call-back "green")}}
.three config -command {puts {(call-back "blue")}}

bind . <Destroy> {puts {(exit)}}
[/text])

(define (call-back color)
	(write-line myout (append ".colorlabel config -background " color))
)


; run event loop
(while (read-line myin)
	(eval-string (current-line))
)

;; eof