The Tcl Command Window

Synergy Research, Inc.
28 August 2002

Introduction

Opening the Command Window

Entering Tcl Commands

Tcl Responses and Messages

Introductory Examples
 

Back to User's Manual Table of Contents


Introduction

The Tcl Command Window is a command line interface to SRView's embedded Tcl/Tk interpreter.  The Tcl/Tk interpreter supports all of the standard Tcl/Tk commands, and also has installed into it many special commands for manipulating the SRView display and operating on images, overlays and other objects defined in the SRIP software package.  The Tcl command window gives the user direct, interactive access to the Tcl/Tk interpreter and all of its commands.

The command window is most useful as a debugging and experimentation tool when developing scripts for SRView.  With it you can experiment with individual commands, set Tcl/Tk variables, examine Tcl/Tk variables a script has set, and run any script without putting it under the control of the Scripts menu.

You might also find the command window useful to run finished scripts and that you have chosen not to place under the Scripts menu.
 

Opening the Command Window

The command window is opened by selecting the Command Window item under the Windows menu of the the SRView main window. It looks like this:



At the bottom of the Command Window is a text entry window for entering commands.  The larger window above the text entry window is a command history window showing previously entered commands.  Prior commands can be recalled to the entry window by clicking on them.  The list of commands in the command history window becomes a scrolling list whenever there are more commands than will fit into the window.
 

Entering Tcl Commands

To enter a commmand, click in the text entry window to make it active and bring up the I-beam cursor.  Type your desired command.  You can edit the command with the usual techniques of an editable text window.  When ready, hit the return key to issue the command.

You can enter any of the standard Tcl commands just as you would at the command prompt of an ordinary Tcl shell.  You can also enter any of the custom Tcl commands implemented in the SRIP package.  SRIP's custom Tcl commands are documented in the SRIP Programmer's Guide, which you can access by clicking here.

Tk commands and widgets of Tcl/Tk are supported too, with the restriction that you should not use the Tk main window (.), but should create other toplevel windows as you need them.  This is explained in the SRIP Programmers manual page on Tcl/Tk scripting in SRView.

Tcl Responses and Messages

The Tcl interpreter sends anything it has to say to you to the terminal window from which you invoked SRView.  So, it is good to organize your screen at the very beginning of an SRView session so that the terminal window is visible while you work.  Resizing it to show just a  few lines and moving it to the bottom of the screen usually works well.
 

Introductory Examples

Here are a few commands to try the first time you experiment with using the command window.  First make sure the terminal widow from which you invoked SRView is visible so you can see the responses. Type
puts "Hello World"
puts is the Tcl command to print a string. Type
puts [pwd]
This will report your current working directory.  pwd is the familiar Unix command for printing the current working directory; it is a standard Tcl command too. Type
ls
ls is the Tcl command for listing the contents of a directory.  So, you should get a listing of what is in the working directory.  Several of the other familiar Unix commands are Tcl commands too.

Here is a less trivial example that may come in handy as you create ROIs for your images.  Let's change the label of the ROIs in an image.  This uses one of the custom Tcl commands written for the SRIP package.  First, go to the main window and display an image.  If the image doesn't have some ROIs, draw some, giving them whatever label you like.  For the sake of this example we will refer to the  current label of the set of ROIs as currentLabel.  Now, let's change all the currentLabel ROIs to have a label of "dental_floss".  To do this, go to the command window and give the command

RelabelRois currentLabel dental_floss
where of course you have substituted for currentLabel whatever is the true current label of your ROIs.  Now if you move the cursor to the image in the main window you will see the currentLabel ROI labels have changed to "dental_floss".

You can put the ROI labels back the way they were by using the RelabelRois command again, i.e.,

RelabelRois dental_floss currentLabel