[R-gui] pseudo radiobutton from check boxes
Adrian DUSA
adi at roda.ro
Sun May 28 15:45:05 CEST 2006
Dear list members,
I have a question related to tcltk programming. I'd like to create 4 check
boxes with different options; that's easy, but I want the 4th option to
deactivate the first three and viceversa: if any of the first three check
boxes has been activated, this should deactivate the fourth check box.
I've written a draft code below, but I feel I misunderstand the usage of
"command". In my mind, this is only activated when the user presses the
button with the mouse. Instead, it seems like the command is activated each
time when the button chages its state. Is there another option I could use
for this purpose?
Thank you in advance,
Adrian
require(tcltk)
top <- tktoplevel()
cbOptions <- c("option1", "option2", "option3", "option4")
cbLabels <- c("Option A:", "Option B:", "Option C:", "Option D:")
initialValues <- c(0, 0, 0, 0)
cbVariable <- tclVar("0")
option13Command <- function() {
tkconfigure(option4CB, variable=cbVariable)
}
option4Command <- function() {
tkconfigure(option1CB, variable=cbVariable)
tkconfigure(option2CB, variable=cbVariable)
tkconfigure(option3CB, variable=cbVariable)
}
option1CB <- tkcheckbutton(top)
option1Variable <- tclVar(initialValues[1])
tkconfigure(option1CB, variable=option1Variable, command=option13Command)
tkgrid(tklabel(top, text=cbLabels[1]), option1CB, sticky="e")
option2CB <- tkcheckbutton(top)
option2Variable <- tclVar(initialValues[2])
tkconfigure(option2CB, variable=option2Variable, command=option13Command)
tkgrid(tklabel(top, text=cbLabels[2]), option2CB, sticky="e")
option3CB <- tkcheckbutton(top)
option3Variable <- tclVar(initialValues[3])
tkconfigure(option3CB, variable=option3Variable, command=option13Command)
tkgrid(tklabel(top, text=cbLabels[3]), option3CB, sticky="e")
option4CB <- tkcheckbutton(top)
option4Variable <- tclVar(initialValues[4])
tkconfigure(option4CB, variable=option4Variable, command=option4Command)
tkgrid(tklabel(top, text=cbLabels[4]), option4CB, sticky="e")
--
Adrian DUSA
Romanian Social Data Archive
1, Schitu Magureanu Bd
050025 Bucharest sector 5
Romania
Tel./Fax: +40 21 3126618 \
+40 21 3120210 / int.101
More information about the R-SIG-GUI
mailing list