I created a GUI window with tcltk
package in R. The window looks like this one:
When I add radio buttons to or remove them from the window (by pressing buttons "Add C" or "Del A"), the window resizes.
How can I prevent this behavior and create a window which can contain, say, five rows of radio buttons without resizing and does not resize when I delete the buttons.
My code:
library(tcltk)
library(tcltk2)
top <- tktoplevel()
# Create buttons
onEXIT <- function() {tkdestroy(top)}
onDELETE <- function() {tkdestroy(buttonA)}
onADD <- function() {tkgrid(buttonC)}
butOK <- tk2button(top, text = "Exit", command = onEXIT)
butADD <- tk2button(top, text = "Add C", command = onADD)
butDELETE <- tk2button(top, text = "Del A", command = onDELETE)
tkgrid(butOK, butDELETE, butADD)
# Create radiobuttons
buttonA <- tkradiobutton(top, text = "A")
buttonB <- tkradiobutton(top, text = "B")
buttonC <- tkradiobutton(top, text = "C")
tkgrid(buttonA)
tkgrid(buttonB)
The solution is simple using tkpack.propagate
. In your case:
top <- tktoplevel()
tkpack.propagate(top, FALSE)