tkappdefaults: Tk options database routines

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

Description

This tkloadappdefaults method provides a high-level method that allows an application to load the Tk options resource database from various application-default files.

Usage

1
2
tkloadappdefaults(classNames,
                  priority="startupFile")

Arguments

classNames

character vector specifying class names, though typically just the name of the application

priority

character string (or integer) specifying priority level for this option. Default is "startupFile"

Details

The Tk options database is loaded from user-specific defaults files, such as ‘.Xdefaults’, and resource databases loaded into the X server. The package will attempt to load its resources upon startup, following the X11R5 method of merging app-default files from multiple sources. The standard X11 paths are searched first, followed by paths specified by the environment variables XFILESEARCHPATH, XAPPLRESDIR, XUSERFILESEARCHPATH, respectively. Unlike X11, ALL matching files will be loaded, not just the first.

The value of each of the environment variables XFILESEARCHPATH and XUSERFILESEARCHPATH is a colon-separated list of pathnames.
The pathnames may contain replacement characters as follows:

%N value of the application's class name
%T value of the file's type, the literal string "app-defaults"
%C customization resource
%L language, locale, and codeset (e.g., "ja_JP.EUC")
%l language part of %L (e.g., "ja")

If getOption("verbose") is TRUE, a traceback of all pathnames considered is displayed, regardless of existence.

Value

Though invoked for its side-effect, returns (invisibly) a list of all pathnames from which resource loading was attempted.

Author(s)

P. Roebuck proebuck@mdanderson.org

See Also

optiondb_readfile

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  ## Not run: 
## Set directory paths for app-defaults processing
homedir <- path.expand("~")
xuserfilesearchpath <- paste(file.path(homedir, "%L", "%T", "%N%C"),
                             file.path(homedir, "%l", "%T", "%N%C"),
                             file.path(homedir, "%T", "%N%C"),
                             file.path(homedir, "%N.ad"),
                             sep=.Platform$path.sep)
Sys.setenv(XAPPLRESDIR=system.file())
Sys.setenv(XUSERFILESEARCHPATH=xuserfilesearchpath)

## Create user 'app-defaults' directory, if necessary
appdefaultsdir <- file.path(homedir, 'app-defaults')
if (!file.exists(appdefaultsdir)) {
    mkdir(appdefaultsdir)
}

## Create some fake resource files
classname <- "Foo"    ## For an R Tcl/Tk GUI named "foo"
customization <- "-color"
appdefaultsfiles <- c(file.path(homedir,
                                sprintf("%s.ad", classname)),
                      file.path(appdefaultsdir, classname),
                      file.path(appdefaultsdir,
                                sprintf("%s%s", classname, customization)))
file.create(appdefaultsfiles)

## Load application defaults
message('*** loading application defaults')
options(verbose=TRUE)
tkloadappdefaults(classname)
cat('\n')

## Add customization aspect
optiondb_add("*customization", customization)

## Load application defaults
message('*** loading application defaults (customized)')
tkloadappdefaults(classname)

## Cleanup
on.exit(file.remove(appdefaultsfiles))
on.exit(options(verbose=FALSE), add=TRUE)
on.exit(optiondb_add("*customization", ""), add=TRUE)
  
## End(Not run)

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