Introduction to TCL/TK
Upon completion of this class, the student will be able to write useful TCL programs to automate operating
system tasks and add scripting capabilities to C programs. Students will also be introduced to TCL's GUI
capabilities through Tk toolkit.
The format of the class is mixed lecture/lab, with lab exercises immediately following each major topic. The lab
exercises are intended to reinforce the preceding lecture topic(s), and are designed to be directly applicable in
an EDA context.
Syllabus
Day 1
|
Day 2
|
Introduction
- TCL uses
- Comparison to other languages
Getting Started
- Creating a TCL program
- tclsh and wish interactive shells
- Loading a script
- Using a TCL debugger
TCL Basics
- Command syntax
- Grouping and quoting
- Data types
- Variables
- Evaluating expressions
TCL Commands
- Control flow commands (if, switch)
- Loops
- Catching errors
String processing
- The string command
- The format command
- String matching
- Regular Expressions
Lists
- Creating lists
- Modifying lists
- Sorting and searching lists
TCL I/O
- Standard file I/O
- Opening files
- Opening sockets
- Binary I/.O
TCL Arrays
- Creating arrays
- Working with arrays
- Data structures using arrays
Procedures
- Creating procedures
- Scope
- The upvar and global commands
TCL in the Unix environment
- Executing programs
- Working with files
- Working with directories
- Environment variables
|
TK Basics
- Widgets
- Widget attributes
- Resources
Arranging Widgets with Pack
- The 'cavity' model
- Stacking
- Anchoring
- Padding and filling
Arranging widgets with Grid
- Basic grid
- Row and column spanning
- Row and column constraints
Tk Events and Binding
- The bind command
- Focus
- Commands
- Key events
- Mouse events
Basic TK Widgets
- Labels
- Buttons (push, radio, check)
- Entry
- Frames
- Toplevel
Menus
- Menubuttons
- Menu bars
- Pop-up menus
Scrollbars
- Creating scrollbars
- Controlling scrollbars
Listboxes
- Creating listboxes
- Listbox binding and control
Text widget
- Text indices and marking
- Inserting text
- Tags
Canvas widget
- Coordinates
- Canvas elements (arc, line, bitmap, polygon, text, rectangle, etc.)
- Tags
Combining TCL and C
- TCL Objects in C
- TCL Commands in C
- Starting a TCL interpreter
- Creating a stand-alone executable
|
Prerequisites
Students will need to have a working knowledge of UNIX operating system. Also, basic programming experience in C
or UNIX shells is highly recommended.