Description Usage Arguments Details Value Author(s) See Also Examples
This tkloadappdefaults
method provides a high-level method
that allows an application to load the Tk options resource database
from various application-default files.
1 2 | tkloadappdefaults(classNames,
priority="startupFile")
|
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 |
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.
Though invoked for its side-effect, returns (invisibly) a list of all pathnames from which resource loading was attempted.
P. Roebuck proebuck@mdanderson.org
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.