tkoptiondb: Tk options database routines

Description Usage Arguments Details Value Author(s) See Also Examples

Description

These functions allow interaction with the Tk options resource database.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
optiondb_add(pattern,
             value,
             priority="interactive",
             verbose=FALSE)
optiondb_get(widget=".",
             rsrcName,
             rsrcClass,
             verbose=FALSE)
optiondb_readfile(filename,
                  priority="userDefault",
                  verbose=FALSE)

Arguments

pattern

character string containing the option being specified, and consists of names and/or classes separated by asterisks or dots, in the usual X format

widget

object of the class tkwin or character string specifying Tk widget from which to retrieve resource

filename

character string specifying pathname to resource file

value

character string specifying text to associate with pattern

rsrcName

character string specifying resource name

rsrcClass

character string specifying resource class name

priority

character string (or integer) specifying priority level for this option

verbose

logical scalar. If TRUE, displays the Tcl command

Details

optiondb_add adds an entry into Tcl options database with given priority; optiondb_readfile adds a file's contents. To clear an entry, invoke optiondb_add with an empty string for value.

optiondb_get fetches a value from Tcl options database.

There is a fundamental difference between the way Tcl handles options and the way Xt handles options; Tcl has separate priorities and within a level prefers the latest matching option, Xt prefers options with "more exact" specifiers and has no level semantics.

A resource class name begins with a capital letter; the resource name begins with a lowercase letter.

There are four primary priority levels. From lowest to highest, they are:

widgetDefault

Level 20. Used for default values hard-coded into widgets.

startupFile

Level 40. Used for options specified in application-specific startup files.

userDefault

Level 60. Used for options specified in user-specific defaults files, such as .Xdefaults, resource databases loaded into the X server, or user-specific startup files.

interactive

Level 80. Used for options specified interactively after the application starts running. (default)

In addition, priorities may be specified numerically using integers between 0 and 100, inclusive. However, the numeric form is discouraged.

Value

The optiondb_get method returns a tclObj object representing the Tcl variable. Use the tclvalue method to extract its character string value.

The other methods are invoked for their side-effect.

Author(s)

P. Roebuck [email protected]

See Also

tclvalue

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
  ## Not run: 
## Set a couple button resource values
optiondb_add("*Button.background", "red", "startupFile")
optiondb_add("*Button.width", 100, "startupFile")

## Even make up "fake" application-specific resources
optiondb_add("*foo", "bar", "userDefault")

## Prove it works
toplevel <- tktoplevel()
tkpack(button <- tkbutton(toplevel)) # large red button appears

## Fetch "fake" application-specific value
foo.obj <- optiondb_get(rsrcName="foo", rsrcClass="Foo")
foo <- as.character(tclvalue(foo.obj))  # bar

## Read an application-defaults file containing resources
optiondb_readfile("/path/to/app-defaults/myapp.ad")
  
## End(Not run)

tclish documentation built on May 2, 2019, 4:53 p.m.