Configureth - A 'Teaching Hypertool' for Tk's configure command This is a teaching hypertool in the sense that its sole purpose is to change and enhance other Tk applications. You can enter some parameters to tk's configure command, click on the Configure button and then click on any widget in any Tk application. The program will execute Tk's configure command on whatever widget is clicked on. You can therefore use this program to interactively configure any currently visible Tk widget, including things like changing its colors and fonts. By using multiple-clicks and some keys, you can cause your changes to be remembered in the application, and even across different Tk applications. Widgets of Configureth The Configure Button Click on Configure to start configuring widgets. Every subsequent mouseclick will configure another set of widgets until the mouse is clicked over a non-Tk window or the root window, or the Configure button is clicked again. When doing configures, the cursor changes to a cross, and all mouseclicks get shunted to configureth. See below for how to save configurations. The Configuration Menu and Entry Enter some arguments to tk's configure command in the configuration entry, such as '-bg black' or '-font 9x15'. When configuring the widget, the contents of this entry get passed to the widget being configured. You can have multiple configurations like "-bg black -fg white" in the configure entry. If you leave the entry blank, configureth will return all configurations of the current widget. If you only leave one word (like "-bg"), configureth will return that particular configuration for the widget, in accordance with Tk's configure command. The configuration menu can be used to remember previous commands. Click on the "+" button to record a configure command, and it gets added to the menu. Selecting a command on the menu brings up that command. All command-line arguments to configureth get added as commands to the configuration menu. Various Configuration Buttons (Color, Cursor, File, Font) These buttons are useful for selecting appropriate values for the configuration entry. For example, after entering "-background " in the configuration entry, you can click 'Color', which brings up a color selection dialog box. When you leave the dialog box, the color you selected is entered in the configuration entry, at the location of the insert cursor. You can likewise use the Cursor button to select an appropriate cursor. And Font selects an appropriate font, and File selects an appropriate File. Kudos to Sven Delmas for giving us XF! (from whence these selectors came!) The Defaults Menu and Entry This indicates the location of your resource-defaults file. This starts out as 'configureth.resources', which will get created and store the output of any resources you indicate. However, you can change this to any resource file, such as ~/.Xdefaults. As with the Configure menu, you can remember resource files by clicking on the '+' next to the Defaults menu, and you can bring up any file in the the Defaults menu by selecting that menuentry. The output entry. This entry is filled with either: 1. Error message from invalid configure command. 2. Tk's output from incomplete configure command such as ".foo configure -bg" 3. Complete configure command if successful. (This is the command that was executed in the remote interpreter.) 4. Text that gets appended to your resources-defaults file, if you do triple-clicking. Semantics of configurations. While configuring, you can do the following: If you are just messing around, and don't want your configurations remembered, just use a single click. This executes tk's configure command on the widget, but the new configuration will be forgotten as soon as the widget is destroyed. Try this now. Put: -background red in the configuration entry, and then click button 1 on this text window. However this configuration will be forgotten. To see this, click on 'OK' at the bottom, and then select Help again. Your configuration is now forgotten. If you would like the remote program to remember the configuration, use a double-click instead. This will add the configuration to the options database in the remote program. So if the widget is destroyed, and recreated without overwriting your configs, your configs will still remain visible. However, your configuration will still be forgotten when the application quits. You can try this here, by double-clicking button 1 on this text widget. Now, if you click on 'OK', and select 'Help' again, the text will still be red. If you don't like a red background, you can quit configureth and start it up again, or you can configure this text with a different color. If you would like the new configuration remembered the next time the program starts up, do a triple-click. This appends the configuration to your defaults file. (which should be an application-specific resource file or ~/.Xdefaults). Be aware that your configuration will only be used if the application doesn't specify a different configuration for that widget. Don't try this here, unless you'd like this text to have a red background forever. To undo it, you will have to edit your resources file. Now, you can work with just one widget, or with a group of widgets, bu using different mousebuttons. If you just want to work with one widget, click button 1 over that widget. If you want to configure all the similar widgets in a group (such as all the buttons in a row), you can try clicking button-2 over one of them. This may or may not work on the set of widgets you want, but it will only affect widgets of the same class as the one you clicked on. (i.e. if you clicked on a scrollbar, only other scrollbars will be affected) For example, with your configuration entry reading: -background red click button 2 on the Help button. All three buttons are now red. Of course, this will be forgotten next time you run configureth, unless you want to triple-click on the Help button. (Clicking on Configure or Quit won't work, they exit configure mode.) Also notice that the OK button underneath this text is unchanged. However, button-2 won't affect more than one of the entries. This is because they are packed differently in the configureth window. If you want to configure all the widgets of one class in a program, use Button-3. You can use Button-3 to configure all of the entries in configureth, for example. You can use any number of clicks with any of the three mousebuttons. All of the above steps can configure any currently visible widget with varying degrees of permenance. But they say nothing about new widgets that may get created. To see this, put -foreground blue in the configuration entry, click on OK to exit this Help session, click on the Configure button, and double-click button-3 on the Help button. This will cause all currently-visible buttons to change their text to blue. But, when you exit configure mode, by clicking on Configure again, and select Help, you will notice that the 'OK' button is not blue; it didn't exist when you did the configuring. To have new widgets configured automatically, you must use Shift when configuring. Try the same configuration again, only use Shift-Double-Button-3 this time. When you select Help again, the OK button will now be blue. Ok, you can now do any configuring inside a single application, but all your configurations will be forgotten as soon as you quit. To have them remembered, make sure the Defaults entry has a good file for saving configurations (~/.Xdefaults for example), and triple-click on a widget. You can do triple-clicking with any button, and you can use Shift to specify that all future widgets receive your new configuration. There's just one last thing. Triple-clicking will save your configuration for whatever program controls the widget you clicked in, but no other programs will care. If you want a configuration to apply to all Tk widgets of some class in an application, use Control while clicking (you should already be using Shift to indicate a class of widgets, instead of just individual widgets). Here are some example configurations (see Tk's options manpage for more) -background -foreground Change background or foreground to specified color. -text Change text in the widget to specified text. (Most Tk widgets that can contain text will have text specified by the program, so while you can change text in a program on the fly, you probably won't be able to save the changes; they'll get overridden by the program.) -bitmap Change bitmap in the widget. Sample bitmaps include: error, hourglass, grey25. To use a file as a bitmap, precede the filename with '@'. -font Change font of text to specified font. -cursor Change mouse cursor, including foreground color, background color, and shape. -relief Specifies the 3-D effect desired for the widget. Acceptable values are raised, sunken, flat, ridge, and groove. The value indicates how the interior of the widget should appear relative to its exterior; for example, raised means the interior of the widget should appear to protrude from the screen, relative to the exterior of the widget. -borderwidth Change size of the widget's border. -padx -pady Change size of the widget's horizontal or vertical padding. -geometry x -height -width Specifies the geometry of a widget. Bugs / Limitations As previously mentioned, while you can save new configurations over any program, that program may still override your new configurations. There is no way to circumvent program-defined configurations permenantly; you'll just have to reconfigure them on the fly. Configureth can reconfigure entire text widgets, however it cannot reconfigure tags inside text widgets. Similarly, configureth can reconfigure entire canvases, and it can configure widgets inside canvases, however it cannot reconfigure items in canvases that are not widgets. Copyright Nope. This is free software. Do with it whatever you like. Change it. Make it better. Especially, tell me how you made it better. Disclaimer I don't see how its possible, but if this software crashes your system, destroys your hard disk, posts to alt.flame asking for mail-bombs, etc. etc, I didn't do it, man. :) Author David Svoboda (svoboda@ece.cmu.edu)