Move from the main Æjaks page
Here is a side-by-side comparison between Tcl/Tk and Æjaks. Neither of these will look very pretty, as I have left out any sort of whitespace padding and grid type of layout.
Tk Aejaks
-------------------------------------- ----------------------------------------
# classic Tk style! Tk has reasonable # Aejaks looks pretty awful without some
# (but dated) default style per OS # style, try without and you will agree.
tk_bisque . setDefaultStyle bisque
# Tk doesn't need a top frame for # Aejaks can only pack one component or
# this simple example, but we will # container into ".", so we create a
# add one for consistency # top level Column
# Tk 'frames' don't have a set shape, # Aejaks 'Column' will always pack
# but order child widgets based on # children into column orientation.
# pack options. # Row containers are similarly row oriented.
frame .top Column .top
pack .top Pack .top
frame .top.row1 Row .top.row1
label .top.row1.l1 -text X Label .top.row1.l1 -text X
# Tk has 'entry' widget # Aejaks has 'TextField' widget
entry .top.row1.x TextField .top.row1.x
# pack with options '-side left' # Pack knows parent is a Row
pack .top.row1.l1 .top.row1.x \ Pack .top.row1.l1 .top.row1.x
-side left
pack .top.row1 Pack .top.row1
frame .top.row2 Row .top.row2
label .top.row2.l1 -text Y Label .top.row2.l1 -text Y
entry .top.row2.y TextField .top.row2.y
pack .top.row2.l1 .top.row2.y \ Pack .top.row2.l1 .top.row2.y
-side left
pack .top.row2 Pack .top.row2
frame .top.row3 Row .top.row3
# exit button runs tcl 'exit' # exit button runs Window 'exitApp' method
button .top.row3.exit -text Exit \ Button .top.row3.exit -text Exit \
-command exit -command {. exitApp /}
pack .top.row3.exit -side left Pack .top.row3.exit
button .top.row3.mult -text Multiply \ Button .top.row3.mult -text Multiply \
-command doMultiply -command doMultiply
label .top.row3.result Label .top.row3.result
pack .top.row3.mult .top.row3.result \ Pack .top.row3.mult .top.row3.result
-side left
pack .top.row3 Pack .top.row3
# not an ideal proc, since we have # ditto
# tied the gui widgets to actual # "
# code. Easily fixable, but this # "
# will suffice for comparisons # "
proc doMultiply {} { proc doMultiply {} {
set x [.top.row1.x get] set x [.top.row1.x get]
set y [.top.row2.y get] set y [.top.row2.y get]
set res "can't multiply $x * $y" set res "can't multiply $x * $y"
catch {set res [expr { $x * $y }]} catch {set res [expr { $x * $y }]}
.top.row3.result configure -text $res .top.row3.result configure -text $res
} }NOTE please take care when editing this page to preserve the side-by-side formatting.