TCL_TK a programming language very interesting for applications

TCL and TK is a very interesting programming language for programming of electronic applications in the future.
I compile for these two pet Puppy, which although a more updated version not this is the 8.5, if I found interesting programs that work with this vesion.
Well here I leave the pets, the first thing the Tcl8.5

and second the Tk8.5

There is a very interesting site with lots of examples is as follows

Good example let’s put this code in a simple calculator downloaded from this page:

package require Tk
wm title . Calculator
grid [entry .e -textvar e -just right] -columnspan 5
bind .e <Return> =
set n 0
foreach row {
{7 8 9 + -}
{4 5 6 * /}
{1 2 3 ( )}
{C 0 . =  }
} {
foreach key $row {
switch — $key {
=       {set cmd =}
C       {set cmd {set clear 1; set e “”}}
default {set cmd “hit $key”}
lappend keys [button .[incr n] -text $key -command $cmd]
eval grid $keys -sticky we ;#-padx 1 -pady 1
set keys [list]
grid .$n -columnspan 2 ;# make last key (=) double wide
proc = {} {
regsub { =.+} $::e “” ::e ;# maybe clear previous result
if [catch {lappend ::e = [set ::res [expr 1.0*$::e]]}] {
.e config -fg red
.e xview end
set ::clear 1
proc hit {key} {
if $::clear {
set ::e “”
if ![regexp {[0-9().]} $key] {set ::e $::res}
.e config -fg black
.e icursor end
set ::clear 0
.e insert end $key
set clear 0
focus .e           ;# allow keyboard input
wm resizable . 0 0

If you copy and paste it into a text file, calling this calculadora.tcl”.
And if we installed our two programs or pet above we can run it follows from the terminal:


 And we will see a small calculator.
Shortly to give some examples.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s