Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Tcl/Tk Automation

Posted by TkAutomate (TkAutomate), 18 October 2002
I have Tcl/Tk applications written for Windows NT that I need to be able to automate.  Continuous manual testing for each release is not feasible.  I currently use SilkTest for Win32 testing which works really well.  However, trying to use SilkTest to record windows in Tk causes them to show up as a CustomWin with multiple TkChild tags that are the same.  In other words, SilkTest can't tell the difference between the different widgets and can't be used for automated testing of the Tcl/Tk applications.  

I'm trying to find another program that will allow us to automate the Tcl/Tk applications.  I've read that Tcl was designed to be able to embed into other applications.  Would the TclHttpd Web Server be able to help me with this?  Has anyone else ran across the same problems and found a solution?  

Any information would be greatly appreciated.  


Posted by admin (Graham Ellis), 18 October 2002
Hi, welcome ... have you come across Expect??

Expect adds three  major commands to Tcl  (and Expectk adds 3 major commands to Tcl/Tk):
     spawn      to start another process
     send      to send information to that process
     expect      to wait unil results that match a pattern are received back

In a nutshell, you can make a note of how you do something manually from a command line prompt, then write a sequence of commands like
     I say xxxxxx
     I hear back yyyyy
     I say zzzzzzz
     I hear back aaaaaa
     I say ddddddd
     I get back nothing, and time out

Being program based,  you can vary what's in your outgoing sequences, and you can mak decisions in your program based on what's in the incoming sequences.  One of the really exciting things about Expect is that you can start off (spawn) multiple subporcesses at the same time, and then wait for input from any of them - I think this is relevant to you - and you can tell which of the processes it was that has sent you a reply.

In my daily work, I'm forever plugging together and unplugging networks of computers.   Rather than go all around the network testing out each machine in turn, or manually running a series of pings from one system, I have a script called "tkpingle" that runs all the pings in parallel - thus it's very fast even if a number of my machines aren't on the network and time out.  Is there a parallel here to whet you're looking for??

See for a listing of this program that I describe.  See for details of Expect, download links etc.  See for details of the book on Expect by Don Libes, author of the extension.

I suspect that TclHttpd would be something of a "red herring" in that it's a wev server side application and you really want to run client side Tk. A Tcletmay may help you in this, but .... ummm ... doesn sound like the best way to me from what little I know of your application.    Yes, you can also embed Tcl in your own C program - best reference book if you're considering this is still John Ousterhout's original text  Please let me know if you would like me to post a sample 20 line program that embeds Tcl.

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho