防止窗口大小调整(R中的tcltk)

时间:2017-11-29 02:49:10

标签: r tcltk tcltk2

我在R中创建了一个带有tcltk包的GUI窗口。窗口看起来像这样:

enter image description here

当我向窗口添加单选按钮或从窗口中删除它们时(通过按“Add C”或“Del A”按钮),窗口会调整大小。

enter image description here

如何防止此行为并创建一个窗口,该窗口可以包含五行单选按钮而不调整大小,并且在删除按钮时不会调整大小。

我的代码:

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)

1 个答案:

答案 0 :(得分:1)

使用tkpack.propagate解决方案很简单。就您而言:

top <- tktoplevel()

tkpack.propagate(top, FALSE)