« Making a variable dynamically visible in a Tcl/Tk GUI | Main | Tcl/Tk - updating your display while tasks are running »

December 16, 2007

Using Tcl/Tk resource files for flexible applications

If you're looking to write a Tcl/Tk application that can be flexibly configured, don't forget to use named resources. Here are two displays from the same program:

So - how did I get the difference in colour and text labels?

1. I drew the buttons WITHOUT ANY TEXT AT ALL, and I did NOT specify a background colour either.

2. I specified an option readfile in my code to bring in a file of resources ... to complete those definitions.

3. I actually created the resource file .... which is simply edited when I want to make changes, but don't want to pay for the expense of getting my program changed!

Here's the resource file - for the Orange, White Hill, Hastings example ...

*top.text: White Hill
*bottom.text: Hastings
*background: Orange

Posted by gje at December 16, 2007 12:54 AM

Comments

Well House Consultants Ltd. Copyright 2010