PBSmodelling (version 2.68.8)

setWidgetColor: Update Widget Color

Description

Update the foreground and background colors of a widget

Usage

setWidgetColor(name, radioValue, winName = .PBSmodEnv$.PBSmod$.activeWin, ...)

Arguments

name

the name of the widget

radioValue

if specified, modify a particular radio option, as identified by the value, rather than the complete set (identified by the common name)

winName

window from which to select the GUI widget. The window that most recently receive user input is used by default if winname is not supplied

...

any combination of "fg", "bg", "disablefg", "disablebg", "entryfg", "entrybg", "noeditfg", "noeditbg" arguments, depending on type of widget - see details

Author

Alex Couture-Beil (VIU, Nanaimo BC) and Allen R. Kronlund (PBS, Nanaimo BC)

Details

The setWidgetColor function allows dynamic updating of widget colors during program execution. However, two factors determine whether dynamic color updating is possible for a particular widget: (i) the type of widget, and (ii) the nature of the Tk implementation in the underlying widget library. Thus, a given widget may not support all combinations of colour variables. The following widgets support the corresponding options:

button:

fg, bg, disablefg

check:

fg, bg, disablefg, entryfg, entrybg

data:

entryfg, entrybg, noeditfg, noeditbg

droplist:

fg, bg

entry:

entryfg, entrybg, noeditfg, noeditbg

label:

fg, bg

matrix:

entryfg, entrybg, noeditfg, noeditbg

object:

entryfg, entrybg, noeditfg, noeditbg

progressbar:

fg, bg

radio:

fg, bg

slide:

fg, bg

spinbox:

entryfg, entrybg

text:

fg, bg

vector:

entryfg, entrybg, noeditfg, noeditbg

These options are described in the PBSmodelling User Guide under Appendix A.

Be aware that Tk uses gray for the highlight color during a selection operation. This means that when the background colour is also gray, there is no visual clue that the value has been selected for a copy operation.

Examples

Run this code
if (FALSE) {
local(envir=.PBSmodEnv,expr={
  createWin("label \"hello world\" name=hello", astext=TRUE)
  setWidgetColor( "hello", bg="lightgreen", fg="purple" )
})
local(envir=.PBSmodEnv,expr={
  createWin("vector names=v length=3 values=\"1 2 3\"", astext=TRUE)
  setWidgetColor( "v[1]", entrybg="lightgreen", entryfg="purple" )
  setWidgetColor( "v[2]", entrybg="green", entryfg="purple" )
  setWidgetColor( "v[3]", entrybg="forestgreen", entryfg="purple" )
})
}

Run the code above in your browser using DataLab