- Tcl - Regular Expressions
- Tcl - Built-in Functions
- Tcl - Error Handling
- Tcl - File I/O
- Tcl - Namespaces
- Tcl - Packages
- Tcl - Procedures
- Tcl - Dictionary
- Tcl - Lists
- Tcl - Strings
- Tcl - Arrays
- Tcl - Loops
- Tcl - Decisions
- Tcl - Operators
- Tcl - Variables
- Tcl - Data Types
- Tcl - Commands
- Tcl - Basic Syntax
- Tcl - Special Variables
- Tcl - Environment Setup
- Tcl - Overview
- Tcl - Home
Tk Tutorial
- Tk - Geometry Manager
- Tk - Windows Manager
- Tk - Events
- Tk - Images
- Tk - Fonts
- Tk - Mega Widgets
- Tk - Canvas Widgets
- Tk - Selection Widgets
- Tk - Layout Widgets
- Tk - Basic Widgets
- Tk - Widgets Overview
- Tk - Special Variables
- Tk - Environment
- Tk - Overview
Tcl/Tk Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Tk - Environment
Generally, all Mac and Linux mac come with Tk pre-installed. In case, it s not available or you need the latest version, then you may need to install it. Windows don t come with Tcl/Tk and you may need to use its specific binary to install it.
The Tk Interpreter
It is just a small program that enables you to type Tk commands and have them executed pne by pne. It stops execution of a tcl file in case, it encounters an error unpke a compiler that executes fully.
Let s have a helloWorld.tcl file as follows. We will use this as first program, we run on the platform you choose.
#!/usr/bin/wish grid [ttk::button .mybutton -text "Hello World"]
The following section explains only how to install Tcl/Tk on each of the available platforms.
Installation on Windows
Download the latest version for windows
from the pst of Active Tcl/Tk binaries available. Active Tcl/Tk community edition is free for personal use.Run the downloaded executable to install the Tcl and Tk, which can be done by following the on screen instructions.
Now, we can build and run a Tcl file say helloWorld.tcl by switching to folder containing the file using cd and then using the following step −
C:Tcl> wish helloWorld.tcl
Press enter and we will see an output as shown below −
Installation on Linux
Most Linux operating systems comes with Tk inbuilt and you can get started right away in those systems. In case, it s not available, you can use the following command to download and install Tcl-Tk.
$ yum install tcl tk
Now, we can build and run a Tcl file say helloWorld.tcl by switching to folder containing the file using cd command and then using the following step −
$ wish helloWorld.tcl
Press enter and we will see an output similar to the following −
Installation on Debian Based Systems
In case, it s not available prebuilt in your OS, you can use the following command to download and install Tcl-Tk −
$ sudo apt-get install tcl tk
Now, we can build and run a Tcl file say helloWorld.tcl by switching to folder containing the file using cd command and then using the following steps −
$ wish helloWorld.tcl
Press enter and we will see an output similar to the following −
Installation on Mac OS X
Download the latest version for Mac OS X
from the pst of Active Tcl/Tk binaries available. Active Tcl community edition is free for personal use.Run the downloaded executable to install the Active Tcl, which can be done by following the on screen instructions.
Now, we can build and run a Tcl file say helloWorld.tcl by switching to folder containing the file using cd command and then using the following step −
$ wish helloWorld.tcl
Press enter and we will see an output as shown below −
Installation from Source Files
You can use the option of instalpng from source files when a binary package is not available. It is generally preferred to use Tk binaries for Windows and Mac OS X, so only compilation of sources on unix based system is shown below −
Download the
Now, use the following commands to extract, compile and build after switching to the downloaded folder.
$ tar zxf tk8.6.1-src.tar.gz $ cd tcl8.6.1 $ cd unix $ ./configure —with-tcl=../../tcl8.6.1/unix —prefix=/opt —enable-gcc $ make $ sudo make install
Note − Make sure, you change the file name to the version you downloaded on commands 1 and 2 in the above.
Advertisements