Skip to Main Content
Learning Perl/Tk
book

Learning Perl/Tk

by Nancy Walsh
January 1999
Beginner content levelBeginner
373 pages
9h 43m
English
O'Reilly Media, Inc.
Content preview from Learning Perl/Tk

16.3. Option Databases

Under the X Window System, a file named .Xdefaults in the user's home directory contains configuration information for X applications, including the colors and fonts an application should use. You can create the same type of file for Win32 systems and call it whatever you want. You might use a file like this to let your users change the application's color settings.

Typically the lines in this file look something like this:

screen*background: yellow
screen.button.foreground:			green
screen*font: {Arial} 24 {normal}

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Perl/Tk

Mastering Perl/Tk

Stephen Lidie, Nancy Walsh

Publisher Resources

ISBN: 1565923146Supplemental ContentCatalog PageErrata