View Public Classes








Verilog for Experienced VHDL Designers


























Unix Introduction













Tcl/TK in PDF


Tcl/TK

3 days
70% Lecture/30% Labs
Basic Level

Overview

Tcl (Tool Command Language) is a remarkably simple scripting language that’s easy to learn, yet powerful enough to implement large-scale, distributed applications. Whether you need to build a complex graphical user interface, create a network-enabled application, or develop a cross-platform program, Tcl can help you get the job done in less time than you thought possible. Additionally, the language’s support for Internet access, database access, and internationalization, as well as its stability and robustness, make it well-suited for enterprise-wide applications.

The Tk extension to Tcl allows you to add a full-featured GUI to your application that will have a platform-native appearance on Windows, Unix, and Macintosh. This Tcl extension has proven so popular that it’s been ported as the standard GUI library for other scripting languages such as Perl and Python.

Benefits

From this course you will learn

Basic Tcl/Tk syntax and commands for writing Tcl/Tk scripts

String processing, data structure manipulation, basic process interaction and file handling

How to make applications run faster

How to create clean, maintainable code

How to use basic Tk interface components and how to modify and extend their behaviors and put them together into complex applications

Some advanced features of Tcl/Tk

Note: Included in this course are optional advanced Tk modules covering topics including: the text widget; the canvas widget; menus; and multi-window applications. Depending on course pacing, student experience, and student needs, course delivery can be customized to include these modules as needed.

Intended Audience

This course is recommended for people with a basic programming background who need to gain a working understanding of Tcl/Tk for extracting and manipulating data.

Prerequisites

Students need to be familiar with the basics of programming and the use of a text editor. Although Tcl/Tk can run on a number of operating systems, the course is normally taught in a UNIX/Linux or Windows environment; student need to be familiar with basic file system use (file system navigation; creating/opening files; etc.).

Suggested Follow-On Course:

Interprocess Communication with Tcl

Exploring Expect

Training Approach

This is an intensive, interactive course, which is approximately 70% lecture and 30% lab. Questions are highly encouraged. On the final day, students are given access to a zipped file containing all of the solutions to the labs and the examples used throughout the course.


Course Outline


Day 1

Introduction to Tcl Programming, Part 1

Module 1 — Introduction to Tcl

A Brief History of Tcl

Tcl Resources

The Tcl Interpreters—tclsh and wish

Basic Tcl Syntax

Executing Tcl Commands Interactively

Using “source” to Execute Tcl Scripts

Module 2 — Variables

Creating and Changing Variables

Variables Substitution: Getting Variable Values

Exercise 1

Simulating Pointers in Tcl

Numerical Values in Tcl

Using “incr” for Integer Arithmetic

Module 3 — Quoting and Substitution Rules

Quoting with Quotes Vs. Braces

Nested Quoting Characters

Commands Substitution

Module 4 — Math

Arithmetic Operators and Functions

Integer vs. Floating-Point Arithmetic

Exercise 2

Boolean Expressions

String Comparisons

Module 5 — String Manipulation

Concatenating Strings

Counting Characters

Extracting Characters from Strings

Finding Substrings

Exercise 3

Changing String Capitalization

“Safe” String Comparisons

Formatting Strings

Parsing Strings

Exercise 4

Module 6 — Looping and Conditional Execution

Conditional Execution with “if”

Conditional Execution with “switch”

Looping with “while” and “for”

Exiting Loops with “break”

Skipping Code with “continue”

Proper Coding Style

Exercise 5

Module 7 — Procedures

Defining Procedures

Variable Scope

Giving Procedures Access to the Global Scope

Returning Values from Procedures

Lab 1

Module 8 — Error Handling

What Happens When an Error Occurs?

Analyzing a Stack Trace

Intentionally Generating an Error

Gracefully Recovering from Errors

Lab 2

Module 9 — Lists

What’s a List?

Creating Lists

Merging Lists

Processing List Elements with “foreach”

Extracting List Elements

Sorting Lists

Editing Lists

Converting between Strings and Lists

Lab 3

Performing Timing Experiments

Day 2

Introduction to Tcl Programming, Part 2

Module 10 — Arrays

What’s an Array?

Creating Array Elements

Getting Array Values

Deleting Arrays and Array Elements

Getting Information about Arrays

Processing Arrays and Element of the Time

Converting between Arrays and Lists

Multidimensional Arrays

Complex Data Structures

Module 11 — Advanced Procedures

“Pass-by-Reference” with “upvar”

Lab 3

Default Values for Procedure Arguments

Variable Argument-Length Procedures

Lab 4

Using “eval” to Process Argument Structure

Module 12 — Accessing the Environment

Working with Times and Dates

Accessing Environment Variables

Predefined Global Variables

Self-Executing Scripts

Accessing Script Arguments

Module 13 — Files

Cross-Platform Pathname Manipulation

Accessing Directories Using “glob”

Manipulating Files and Directories

Getting File Attributes

Lab 5

Opening Files for Reading and Writing

Reading and Writing Files

Closing Files

Buffering Issues

Terminal Input/Output

Lab 6

Module 14 — Processes

Executing Processes with “exec”

Process Pipelines

Detecting Error Conditions

Module 15 — A Survey of Popular Extensions

Obtaining Extensions

Using Extensions (the “package” Command)

Descriptions of Popular Extensions

Day 3

Building Graphical User Interfaces with Tk

Module 1 — Introduction to Tk

What is Tk?

Running the wish Interpreter

What's a Widget?

How do You Create Widgets?

The wish Version of “Hello World”

The Event Loop

Treating Tk as a Package

Module 2 — Working with Widgets

Widget Attributes

Widgets as Objects

Configuration Options

Configuring Colors

Configuring Position

Configuring Text

Configuring the Border

Displaying Bitmaps

Displaying Images

Creating Images

Exercise 1

Module 3 — Basic Tk Widgets

Using Widgets

Tcl Variables with Tk Widgets

More on the Event Loop

Checkbuttons

Radiobuttons

Entries

Spinboxes

Widget State

Listboxes

Lab 1

Module 4 — Laying Out Displays with the Pack

Displaying Scrollbars

How pack Arranges Widgets

Positioning a Widget in its Packing Space

Resizing a Widget in its Packing Space

Enlarging the Window

Packing Space vs. Widget Size

Expanding Widgets into the Extra Packing Space

Strategies for Shrinking Windows

Creating and Using Frames

Lab 2

Module 5 — Laying Out Displays with the Grid

Laying Out Displays with grid

Using grid for Regular, Row/Column Layouts

Empty Grid Cells

More Complex Grids

Spanning Cells in a Grid

Aligning and Filling Widgets with grid

Resizable Grids

Lab 3

Combining pack and grid

Module 6 — Events

Overview of Events

A Typical Sequence of Events

Event Types

Basic Event Binding

Event Specification Syntax

Event Matching–The “Best Match” Algorithm

Event Substitutions

Class Bindings

Event Propagation

Binding Tags

Lab 4

Module 7 (Optional) — The Canvas Widget

A Simple Sketchpad

Drawing on a Canvas

Drawing Complex Pictures

Manipulating Canvas Items

Searching for Canvas Items

Tagging Canvas Items

Using Canvas Tags

Using Bindings for Interactive Displays

Cross-Platform Coding

Conflicting Canvas Bindings

“Masking” Conflicting Bindings

Scrolling a Canvas

The Canvas “Viewport”

Screen Coordinates vs Canvas Coordinates

Lab 5

Module 8 (Optional) — The Text Widget

Identifying Positions in a Text Widget

Index Arithmetic

Common Text Widget Attributes

Inserting Text

Deleting and Retrieving Text

Tab Stops

Tagging Text

Manipulating Text Tags

Configuring Tag Attributes

Character-Formatting Tag Attributes

Line-Formatting Tag Attributes

Using Bindings for Interactive Displays

Text Manipulation through Tags

Module 9 (Optional) — Top-Level Windows and Dialogs

Creating, Using, and Destroying Top-Level Windows

Custom Dialogs: Show/Hide Approach

Lab 6

Built-In Dialogs

Module 10 (Optional) — Creating and Using Menus

Adding a Menu Bar to a Window

Adding Menu Items

Adding “Alt Key” Accelerators

Adding “Control Key” Accelerators

Tear-Off Menus

Pop-Up Menus

Menu Buttons

Option Menus

Lab 7

  For more information, contact:
Tom Wille
TM Associates, Inc.
14420 S. Kelmsley Dr.
Oregon City, OR 97045
503-656-4457
503-656-4775 fax

tw@tm-associates.com