Recent Changes - Search:



Tutorial 1 - Editing gedit.tcl

This example will modify the gedit demo application.

We'll start by getting the source for gedit:

  • Bring up the admin interface, ie:
  wize /
  • Navigate down to Gui and double-click on Gedit. When gedit comes up click on Code in the menu.
  • When the source code appears, click on Save and save to /tmp/gedit.tcl.

Using Ted

Let's use the ted programming editor.

  • Go back to admin and double-click on Apps/Ted.
  • In the file open box in Ted type /tmp/gedit.tcl and hit enter.
  • To run the application type <Shift-F5> and then Enter in the dialog.
  • Click on Close to exit the Run.
  • Make any changes you like in Ted and repeat <Shift-F5>, etc.

Note that <Shift-F5> is the same as running the command-line:

  wize -Wall /tmp/gedit.tcl

You might also want to change the timeout, of when the program should be terminated.

Examining Runtime Data

Run the application by hitting <Shift-F5>. But this time decrease the timeout to 0 minutes (disabled). Then click Start.

Once the program is up, use the key/mouse sequence <Control-Alt-Shift-2> anywhere in gedit. This will bring up the Widget Config Editor whose Menu will allow you to explore the code, data and widget options of the running application.

See Explore for details.

Ted Command Completion

Let's try out command completion. Goto proc Main (around line 55), open an empty line, and type the following:

  Entry new .t -

Note how the status-line displays possible matches. Now hit <Control-space> which will bring up the options dialog, eg:

Next select -bg, which will insert it into your line. Then add a single space and type <Control-space> again. This brings up the color dialog.

This demonstrates basic command completion in Ted. In general <Control-space> is used to invoke the completion dialog.

Completion works the same for sub-commands as it does for options. In addition, the status-line at the bottom also shows the current matching extern definition.

Note: in rare cases seeing all sub-commands may require entering a * before <Control-space>.


Let's try out warning detection. Change the above line to:

  Entry new .t -xyz 9

Then hit <Control-s> to save and <Shift-F5> to run. In the bottom of the editor, you should see something like:

/tmp/gedit.tcl:56: warning: for argument #2 "args", the value "-xyz" does not
match type <topts -background tkcolor -bd tkpixel -bg tkcolor -borderwidth
tkpixel -cursor tkcursor -disabledbackground tkcolor -disabledforeground
tkcolor -exportselection bool -fg tkcolor -font tkfont -foreground tkcolor
-highlightbackground tkcolor -highlightcolor tkcolor -highlightthickness
tkpixel -insertbackground tkcolor -insertborderwidth tkpixel -insertofftime
int -insertontime int -insertwidth tkpixel -invalidcommand cmd -invcmd cmd
-justify {choice center left right} -readonlybackground tkcolor -relief
{choice raised sunken flat ridge solid groove} -scrolltile bool
-selectbackground tkcolor -selectborderwidth tkpixel -selectforeground
tkcolor -show .  -state {choice normal active disabled hidden} -takefocus .
-textvariable var -tile tkimage -validate .  -validatecommand cmd -vcmd cmd
-width int -xscrollcommand {cmd p1 p2}> for "Entry new .t -xyz 9" in proc
[::app::gedit::Main] <types,4>.  Warn: Bad ::entry option '-xyz' = '9':
unknown option "-xyz"

The output may seem daunting, but it mostly enumerates the valid values. And clicking on the warning will navigate directly to that line.


The previous example did not kick an error because Entry catches errors in options. So lets insert a real error.

After the Entry line, type:

  set a b c

Then hit <Control-s> to save and <Shift-F5> and run it. This should give you a lengthy traceback in the message window (Just hit <Escape> to close the run dialog).

Now hit <F4> to scroll forward through the warnings (<F3> goes backwards). One of these is the warning for set having too many args.

Trapping an Error

Run the program again with <Shift-F5>, but but click on trap, then click Start to run the program.

This time you should see TclInspect popup stopped at the line of the error.

Note that the stack is still active inside the running program, so you can type Tcl commands at the bottom.

Edit - History - Print - Recent Changes - Search
Page last modified on May 18, 2010, at 06:16 PM