|
|
|
|
|
The first item in each line should be the name of your application unless the options are for your application only. My test application was in a file named screen, so that is what I used as the first keyword in each line. The second keyword (if specified) is a widget type or name (you can specify a name for any widget by adding the -name option to the creation command of that widget). The third keyword is the "class" for which you want to set a default. You can set a default value for any of the options associated with a widget. See Appendix A to find out which class is associated with each widget type. |
|
|
|
|
|
|
|
|
To read in this file, call optionReadfile with the location of the file (for example, "color_options" or "C:/ .Xdefaults" or ".Xdefaults"): |
|
|
|
 |
|
|
|
|
$widget->optionReadfile("filename"); |
|
|
|
|
|
|
|
|
Make sure to include a newline on the last line of this file or you'll get an error that says, ''missing newline on line 2 at C:\PERL\lib\site\Tk\Submethods.pm line 16." This error doesn't make much sense except that the first line number it gives you matches the number of lines in the option file you are trying to read in. If you use $widget->option("readfile", ...) to call the method, you'll get a more sensible error message. |
|
|
|
|
|
|
|
|
As the second argument to optionReadfile you can specify an optional priority, which should be one of "widgetDefault", "startupFile", "userDefault", or "interactive". The default priority is "interactive", which is the highest priority. |
|
|
|
 |
|
|
|
|
$widget->optionReadfile("filename", "widgetDefault"); |
|
|
|
|
|
|
|
|
You can add an option type in the program dynamically by using the optionAdd method (whether or not you have used optionReadfile): |
|
|
|
 |
|
|
|
|
$widget->optionAdd(pattern => value); |
|
|
|
|
|
|
|
|
For example, we can change the font for the entire program like this: |
|
|
|
 |
|
|
|
|
$widget->optionAdd("screen*font", "{Arial} 24 {normal}"); |
|
|
|
|
|
|
|
|
The optionClear method should clear out any current option settings and reread the file (or retrieve them from the resource manager): |
|
|
|
 |
|
|
|
|
$widget->optionClear(); |
|
|
|
|
|
|
|
|
To determine the current setting for the value associated with a specified name and class, call optionGet: |
|
|
|
 |
|
|
|
|
$widget->optionGet (name, class); |
|
|
|
|