Ticket #86: tcltkdemo.pir

File tcltkdemo.pir, 0.8 KB (added by vkon, 5 years ago)
Line 
1# demonstrate Tcl/Tk GUI using NCI
2
3.include 'runtime/parrot/library/TclLibrary.pir'
4
5.sub try :main
6    .local pmc tcl
7    tcl = new 'TclLibrary'
8    .local string res
9    res = tcl.'eval'("return [expr 1.0/3]")
10    print "double is "
11    say res
12    res = tcl.'eval'("return [list a b foo bar]")
13    print "list is "
14    say res
15    res = tcl.'eval'("return {3+3}")
16    print "string is "
17    say res
18    tcl.'eval'("puts this")
19    res = tcl.'eval'("expr {2+3}")
20    print "res="
21    say res
22    res = tcl.'eval'(<<"EOS")
23package require Tk
24pack [button .b -text {useful button} -command {puts this}]
25pack [text .t]
26.t insert end {foo, bar, fluffy}
27pack [button .bquit -text {quit} -command {exit}]
28EOS
29    res = tcl.'eval'("expr {3+3}")
30    print "res="
31    say res
32    tcl.'MainLoop'()
33.end
34
35#
36