[HJG] Simple demo of [Tk]: [label], [entry], [button] and an [image]. Simple Layout with [frame]s and [pack]. No error-checks on input (empty, non-numeric) or overflow of result. ---- #!/bin/sh # Restart with tcl: -*- mode: tcl; tab-width: 4; -*- \ exec wish $0 ${1+"$@"} # EntryDemo02.tcl - HaJo Gurt - 2006-02-02 - http://wiki.tcl.tk/15398 #: Tk-Demo: Enter 3 numbers, show sum and product package require Tk proc Calc {} { #: Calculate results / !! No error-checks !! global A B C P S #set S [ expr { $A + $B + $C } ] #set P [ expr { $A * $B * $C } ] # Force calculation as floating point: set S [ expr { 0.0 + $A + $B + $C } ] set P [ expr { double($A) * double($B) * double($C) } ] } #########1#########2#########3#########4#########5#########6#########7##### frame .f1 ;# Frame for input-fields + button frame .f2 ;# Frame for output label .labA -text "A:" label .labB -text "B:" label .labC -text "C:" label .labS -text "S=" label .labP -text "P=" entry .entA -textvar A -width 11 entry .entB -textvar B -width 11 entry .entC -textvar C -width 11 entry .entS -textvar S -state readonly entry .entP -textvar P -state readonly button .ok -text "OK" -command Calc pack .f1 .f2 pack .labA .entA -in .f1 -side left pack .labB .entB -in .f1 -side left pack .labC .entC -in .f1 -side left pack .ok -in .f1 -side left -padx 10 pack .labS .entS -in .f2 -side left pack .labP .entP -in .f2 -side left #package require Img ;# Images other than .gif image create photo Pic1 -file "tcl.gif" label .labPic1 -image Pic1 pack .labPic1 -padx 4 -pady 4 set A 2147483647 set B 1 set C 2 Calc bind . Calc wm title . "EntryDemo2" focus -force .entA ---- Is there a simple/portable way to check for overflow, when working with integer values ? [Simple Entry Demo 2] ---- [Category GUI]