|
3 days
70% Lecture/30% Labs
Basic Level
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.
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.
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.
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.).
Interprocess Communication with Tcl
Exploring Expect
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.
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
Creating and Changing Variables
Variables Substitution: Getting Variable Values
Exercise 1
Simulating Pointers in Tcl
Numerical Values in Tcl
Using “incr” for Integer Arithmetic
Quoting with Quotes Vs. Braces
Nested Quoting Characters
Commands Substitution
Arithmetic Operators and Functions
Integer vs. Floating-Point Arithmetic
Exercise 2
Boolean Expressions
String Comparisons
Concatenating Strings
Counting Characters
Extracting Characters from Strings
Finding Substrings
Exercise 3
Changing String Capitalization
“Safe” String Comparisons
Formatting Strings
Parsing Strings
Exercise 4
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
Defining Procedures
Variable Scope
Giving Procedures Access to the Global Scope
Returning Values from Procedures
Lab 1
What Happens When an Error Occurs?
Analyzing a Stack Trace
Intentionally Generating an Error
Gracefully Recovering from Errors
Lab 2
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
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
“Pass-by-Reference” with “upvar”
Lab 3
Default Values for Procedure Arguments
Variable Argument-Length Procedures
Lab 4
Using “eval” to Process Argument Structure
Working with Times and Dates
Accessing Environment Variables
Predefined Global Variables
Self-Executing Scripts
Accessing Script Arguments
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
Executing Processes with “exec”
Process Pipelines
Detecting Error Conditions
Obtaining Extensions
Using Extensions (the “package” Command)
Descriptions of Popular Extensions
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
Widget Attributes
Widgets as Objects
Configuration Options
Configuring Colors
Configuring Position
Configuring Text
Configuring the Border
Displaying Bitmaps
Displaying Images
Creating Images
Exercise 1
Using Widgets
Tcl Variables with Tk Widgets
More on the Event Loop
Checkbuttons
Radiobuttons
Entries
Spinboxes
Widget State
Listboxes
Lab 1
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
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
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
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
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
Creating, Using, and Destroying Top-Level Windows
Custom Dialogs: Show/Hide Approach
Lab 6
Built-In Dialogs
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 |