if 0 { <> ---- **Introduction** [MiHa] 2015-05-13: This is a demo for a tcl/tk-program with all the essential GUI-elements. <
> It is a simple invoice-program with menu, entry-form and output (planned: one printed page). All the data is just strings of text, no validation, no calculation. With ideas and code from the following pages: * [m+] * [Ask, and it shall be given # 8] - "grid-layouts" * ... } ---- **Program 1** ======tcl # InvoiceDemo04.tcl - Mike Hase - 2015-05-19 # http://wiki.tcl.tk/29284 # Simple "invoice"-themed GUI-program: menu, form for data-entry, output to screen and printer. # (Menu and output not done yet) global data maxFNr set FieldNames1 {Date Title Name Street City Phone} #set FieldNames2 {art1Nr art1qty art1name art1price price1} set FieldNames2 {Article-Number Quantity Description Price Total} set fNr 0 set artNr 0 # Frame for customer-data: frame .f1 foreach field $FieldNames1 { incr fNr #set data($fNr) $fNr ;## set lb [label .f1.lb$field -text $field] set en [entry .f1.en$field -justify left -textvar data($fNr) ] grid $lb $en -padx 4 -pady 2 grid $lb -sticky e grid $en -sticky ew } # Frame for article-data: frame .f2 incr artNr ;# Todo: extend to more articles foreach field $FieldNames2 { incr fNr #set data($fNr) $fNr ;## set lb [label .f1.lb$field -text $field] set en [entry .f1.en$field -justify right -textvar data($fNr) ] grid $lb $en -padx 4 -pady 2 grid $lb -sticky e grid $en -sticky ew } set maxFNr $fNr # Frame for buttons: frame .f8 button .f8.b1 -text New -command { data0 } button .f8.b2 -text Test1 -command { data1 } button .f8.b3 -text Test2 -command { data2 } button .f8.b4 -text Show -command { showData } button .f8.b5 -text Print -command { printData } button .f8.b6 -text Exit -command { exit } grid .f8.b1 .f8.b2 .f8.b3 .f8.b4 .f8.b5 .f8.b6 pack .f1 .f2 .f8 -side top proc data0 {} { # Clear data in entry-fields for {set f 1} {$f <= $::maxFNr} {incr f} { set ::data($f) "" ##set ::data($f) $::maxFNr ##update ;## } } proc data1 {} { # Fill entry-fields with testdata set ::data(1) "2015-05-13" set ::data(2) "Mr." set ::data(3) "Smith" set ::data(4) "Mainstreet 123" set ::data(5) "Newtown" set ::data(6) "555-6789" set ::data(7) "0815" set ::data(8) "2" set ::data(9) "T-Shirt" set ::data(10) " 9.99" set ::data(11) "19.98" } proc data2 {} { # Fill entry-fields with testdata set fNr 0 set values { "2015-05-14" "Mrs." "Miller" "Highstreet 99" "Oldsville" "555-9876" "0816" "1" "T-Shirt XL" "12.24" "12.24" } foreach v $values { incr fNr set ::data($fNr) $v } } # Todo: proc showData {} { bell } proc printData {} { bell } ### EOF ### ====== ---- **Output** ======none Invoice-Demo: ... ====== ---- **Remarks** This is ''not-yet'' the Alpha-version, ... ---- '''See also:''' * [GUI Primer] * http://wiki.tcl.tk/41210%|%ClockDemo%|% * http://wiki.tcl.tk/10705%|%Category Printing%|% ** [printing] ** [Printing under Windows] ** [Printing text files under Windows] ** [Printing a canvas under Windows] ** [Printing a text file to a lpr printer] ** [Tcl/Tk Printing Support] ** [TkPrint] <> Example | GUI