Widgetscopy

ABU 27-12-2017

Widget-scopy, or or how to deeply inspect widgets properties.

A Widgetscope is a new kind of tool for inspecting and changing properties of widgets in a running application.
A Widgetscope is made up of two parts:

  • a probe systems that must be installed in a running application
  • a set of widgetscopes, i.e. some specialized viewers able to inpect and change the properties of the observed widgets.

When a probe is applied to a widget (i.e. the widget is 'instrumented'), it establish a bidirectional, symmetric channel able to communicate with the widgetscopes.

Every change performed through the widgetscopes is sent to the probe attached to the instrumented widget, and then applied. Conversely, every change performed by the application on the instrumented widgets is sent to the widgetscopes so that they can update their displayed data.

This kind of instrumentation causes a light overload on the application, but only when you put some widgets 'under inspection'. When you close all the widgetscopes, the instrumentation applied to your app is completely deactivated, missing.
Widgetscopes run in a dedicated space fully separated from the application. They run in a separate 'interpreter', so that no conflict with your application's resources (procedures, variables, widgets,...) may occurr. The only parts that are loaded with your application are a set of procedures , confined in a dedicated namespace '::wprobe' that will be used to instrument just your app's widgets you want to inspect.

Widgetscope

Download

wscope 1.0 [L1 ]

Install the package wscope

Wscope package should be installed as a standard Tk package, that is as a subdirectory of one of the directories given by the "auto_path" variable.

Quick Tour

Let's start with a very simple TclTk application like the following

 #-- example1.tcl ---------------------------------------------------------
 button .button1 -text "Hello World" 
 .button1 configure -command  {
   tk_dialog .hello "Hello World!" "what a wonderful world" info  0 "Yeah"
  }
  pack .button1

If you installed the package as suggested, you can run this application by typing the following command:

  • (on Windows)
wish tkcon.tcl example1.tcl -load wprobe -slave "wprobe::quickstart ; tkcon iconify"
  • (on Linux/MacOS)
tkcon example1.tcl -load wprobe -slave "wprobe::quickstart ; tkcon iconify"

The above command in detail:

  • launch the TkCon console
  • run the script "example1.tcl"
  • then load the package wprobe
  • and finally run the tcl command "wprobe::quickstart"
  • and hide the TkCon console.

Start by selecting a widget (press the "Select Widget" button) browse the widgets in the "Widget Selector" window and then choose (double-click on) ".button1".
Now you can inspect and change its properties.
Note that when you click on the "Hello World" button, its attached widgetscope reports the changes (in particular for the "-state" and "-relief" options).
You can also open (or deiconify) the TkCon console and type a command like the following

  .button1 configure -background orange

or conversely, you can act through the widgetscope; press the "-background" button, or type something in any text-box