Next
Contents 
Tcl/Tk Tutorial - Create GUI using Tk with Tcl Language
Tcl/Tk Tutorial - Create GUI using Tk with Tcl Language

A Tcl(Tutorial for Cool Languages) for Tcl/Tk

Tcl/Tk Logo

Tcl/Tk - one language, many uses. It can be used for GUI(Graphical User Interface) development with the powerful TK. Tcl/Tk runs as a plugin from web browsers made by Netscape and Microsoft. So it can be used instead of JavaScript and VBScript. It is a CGI language and can be used in servers. Tcl-Tk is also extremely extendable - Tcl/Tk is valuable to C/C++ programmers who want to learn a high-level scripting language for their user interfaces or for integrating pieces of a large system.

Tcl stands for Tool Command Language. Tcl and Tk, its associated graphical user interface toolkit, was created by Professor John Ousterhout of the University of California, Berkeley. Tcl is a scripting language that runs on Windows, UNIX and Macintosh platforms. Tk is a standard add-on to Tcl that provides commands to quickly and easily create user interfaces. Even though Tcl was originally created on UNIX, your Tcl/Tk scripts should run the same on all supported platforms, except for a few differences.

Tcl is a very simple, open-source-licensed programming language and provides basic language features such as variables, procedures, and control, and it runs on almost any modern OS, such as Unix, Macintosh, and Windows 95/98/NT/XP computers.

Tcl was originally developed as a reusable command language for experimental computer aided design(CAD) tools. The interpreter was implemented as a C library that could be linked into any application. It is very easy to add new functions to the Tcl interpreter, so it is an ideal reusable "macro language" that can be integrated into many applications.

But Tcl is a programming language in its own right, which can be roughly described as a cross-breed between LISP/Scheme (with less parens) and shells (with more powerful structuring). You can write any number of programs in Tcl, just as you can in any other language. Tcl programs are usually called "scripts" because the programs do not need to be compiled into a machine-readable form.

Enough history(..yawn..). Now lets move on to the tutorial. Go to the contents page - or skip straight to the important parts.

Author - Binny V A
About the Author
Personal Site Binny V A
Tutorial Feedback

Next
Contents 

Comments

Mariusz at 18 Mar, 2007 03:23
I have lerned a lot from here, Thanks
Reply to this.
Ari at 17 Apr, 2007 08:05
Dear Sir,
My Name is Ari.I am From Indonesia,I am interesting with your experience.Now i am making paper about softswitch simulation using NS2(TCL).
And i feel confused about the scripts of it.Would you please do me a favor?Thank you for your attention.
Reply to this.
Binny V A at 17 Apr, 2007 11:45
I am sorry - but I have not yet heard of that application. I could not help you out here.
Reply to this.
tamgo at 16 May, 2007 06:03
Excellent resource! Thanks, this helped a lot.
Reply to this.
Souaveck at 19 May, 2007 11:46
Hey Guys! Great page!!
The one thing which would be very usefull is a screeshot of the results at the end of each tutorial. It makes easier to find something what beginners (as me) are looking for.
Thanks a lot!! Great job. I can say that this page is definatelly "zajebista" :-)))
Regards
Souaveck
Reply to this.
Anonymous at 22 May, 2007 02:09
This document is awesome!!!
Any clues on how do display x-y plots?
Reply to this.
Apud at 05 Jul, 2007 11:53
I would suggest using BLT for plots.

blt::graph works very nicely and you can also generate PS or print out the plot.
Reply to this.
himanshu pandey at 25 May, 2007 05:15
Very good tutorial for beginners
However one more piece of information could be added like how do run scripts
like the script requires packages like BWidget else it gives Err: invalid command
But overall I would give 8.5 out of 10 to the contents and presentations style
Reply to this.
Abhishek Kumar at 13 Jul, 2007 04:58
A great great tutorial. it was fun going through it and trying out the programs myself.
Thank you very much. you have given me a solid base in tcl\tk and now I can go further.

I have one problem, the widgets packed through grid or pack commands don't resize themselves when the main window is resized. Can u please tell me how to do that?

And why don't you give some more information about yourself on your site?
Reply to this.
Anonymous at 02 Apr, 2008 10:44
We need to bind a handler (a procedure) to the <Resize> Event. In the handler you can re-create all the elements inside the window based on the size of the newly-resized window.

However, I am not sure if TCL defines such an event.
Reply to this.
Fruttenboel at 21 Jul, 2007 03:30
While looking for something else I ran into an example of TCL/TK and I liked it.
Looking for a nice tutorial I ran into your site and I like it as well.

You are a gifted writer.

I want TCL/TK on the side of Mocka for controlling my Parilux feedback device:
verhoeven272.nl/fruttenboel/parino/palux1.html
Reply to this.
Anonymous at 04 Aug, 2007 02:13
Your Tcl/Tk tutorial is the best I could find on google!
Thanks!
Please keep writing and add more things to your tutorials!
Reply to this.
Anonymous at 30 Aug, 2007 02:42
hello sir,

i want to know,how to get the output on a command prompt.that is like java,we give the command javac filename ---> java file...we will get output in the command prompt...similarly we write the tcl/tk code in wordpad(.tcl) and how can we get the output on command prompt
Reply to this.
Binny V A at 30 Aug, 2007 06:09
Try 'wish FILE.tcl'
Reply to this.
The New Mr at 19 Sep, 2007 05:22
Excellent little tutorial man! Learnt a lot from it in a short space of time. There are a few grammatical mistakes here and there but you make up for it with your humor spread out over the tutorial. Loved the bit about the pizza :)
Reply to this.
Binny V A at 17 Jan, 2008 12:09
Thanks :-)
Reply to this.
Mr x at 19 Sep, 2007 07:12
HI,
HOW to run another command using TK.
like i want to run another application when a button is clicked.
Reply to this.
Binny V A at 19 Sep, 2007 11:34
Use the exec function.
Reply to this.
Anonymous at 05 Oct, 2007 05:44
Hi can anyone tell me how to write a tcl proc where I can get admits from all the days till they become discharges and it should be displayed every day.
ex:Like say Charlie got admitted on 10/01 and discharged on 10/4
i want to see him on the frl every day while I ftp
10/01 charlie
10/2 charlie
10/3 charlie
104/ charlie as discharge
Reply to this.
Tcl newbie at 06 Oct, 2007 03:27
Hi all,

I am new to tcl i have a tcl script which has mysqltcl package. I want to use this as tclet i,e view this tcl script inside browser. i downloaded plugins for that. But browser does't get the mysqltcl package. But it runs fine when run from wish. any suggestion will be much appreciated

Reply to this.
Anonymous at 26 Dec, 2007 09:56
dear sir,
i m new tcl/tk i want to learn it plz tell me hw can i proceed in tcl/tk , i dnt knw any scripting langauge
Reply to this.
Anonymous at 22 Jan, 2008 02:23
sir
can u give me the coding for database connectivity using tcl script to sqlserver 2005
Reply to this.
Anonymous at 23 Jan, 2008 11:48
Hello Sir/Madam,

I am unable to find the "LIBMYSQLTCL.SO" file . Can anyone suggest me where can i get the exact file . Please provide me a solution ..
Reply to this.
Anonymous at 24 Jan, 2008 01:05
i have loaded the required dlls but it give the error message saying "cannot connect to localhost <10061> . can any one suggest me a solution..
Reply to this.
Anonymous at 23 Mar, 2008 08:50
HI! i require a VHDL code for creating a GUI screen with one or two radio buttons. I think it can be done using TK. Can u please gimme a code for the same? its pretty urgent.
Reply to this.
Anonymous at 27 Mar, 2008 04:01
HI! I need a code for creating a GUI screen for data entry. There are two input data to be obtained from the user. I am using Modelsim SE 6.0 version. This data entry screen is part of my project. I am unable to write the code for it. If not the code, atleast gimme guidelines abt using tcl/tk in modelsim. r gimme a simple program that i can execute using modelsim so that i understands how tcl/tk is used in modelsim.
Reply to this.
Anonymous at 07 Apr, 2008 07:40
Hi Binny,

Thanx a lot for your great work on this site & i am a VLSI design engineer (IC design), i was not having any knowledge of scripting languages like TCL/Tk i got your site and downloaded it and trying to learn it properly, but my main intention of learning is EDA (Electronics Design Automation) using TCL/TK. Though it works well for text file operations/data processing. But, could you be able to give me a clue or some way that would automate the geomatry based placement & routing of layers in IC layouts like eg. metal layers, schematic circuit symbols in library (of a tool env. - i am hav ing this thing but only need a procedure to route them) & pcells (parametric cells designed and characterized for multiple climatic & surrounding parameters) just i wanted to know how to move the polygons (cells/physical graphical instances/polygons like standard cells/basic building blocks in IC layout editor (like Cadence - Virtuoso XL/LE or Magma Blast fusion or IC compiler...etc)), may be it's coordinate based or grid count based in the design editors. i have also tried running examples of GUI development to get a clue of generating some grraphical symbols/may be it would give an idea of P&R of instances for buttons or entry boxs, may know how to execute these commands is there some thing special library or functions to be loaded in some location to call and run these commands. I wanted it for home usage for learning in Windows env. would these command be able to run in this OS or could only be ran on linux/solaris/unix? Would really grateful if you can give a funda/direction of in which i should think for doing moving & propagating some layers having specific dimentional ans spacing constraints.

Thanks & Regards,
Ravi.
Reply to this.
Sudoku Maniac at 07 Apr, 2008 04:52
does it work on mobiles ?
Reply to this.
Brinda at 01 May, 2008 03:58

Dear Sir,
Using TCl/TK I have created a GUI,now i want to store and retrieve data using the same language tcl/tk ..,could u please help me in that sir.,I am helpless.
Regards,
Brinda.S
Reply to this.
Comment


Comment




Comment Formating : HTML tags a, strong, em, b, i, code, pre, p and br allowed. Other tags will be shown as code(< will become &lt;). Urls, Line breaks will be auto-formated.
Subscribe to Feed