简体   繁体   中英

Prevent from window resizing (tcltk in R)

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM