Tk commands have got options and arguments which are strings.
set text1 [text .t]
pack $text1
$text insert 1.0 "Hello World"
In Scheme, the arguments have data types as needed:
(define text1 (tk 'create-widget 'text))
(tk/pack text1)
(text1 'insert '(1 . 0) "Hello World")
Scheme data are translated to Tk arguments as follows:
Data type
|
Scheme
|
Tcl/Tk
|
false
|
#f
|
0
|
true
|
#t
|
1
|
keywords
|
#:keyword
|
-keyword
|
widgets
|
(tk 'create-widget 'frame)
|
.frame
|
menu commands
|
#:command (lambda () ... )
|
-command {...}
|
lists
|
(item1 item2 ...)
|
{item1 item2 ...}
|
dotted pairs
|
(2 . 4)
|
2.4
|
numbers
|
9
|
9
|
strings
|
"arg"
|
arg
|
symbols
|
'arg
|
arg
|
In some cases, you are free to use Tk-style data, e. g. 1 and 0 for #t and #f . In some other cases you must use Scheme-style data, e. g. associated commands.—My first advice is: where legibility matters, use Scheme-style data. My second advice is: legibility matters always.
© Author
| Home
| Sitemap
|