我在R中创建了一个带有tcltk
包的GUI窗口。窗口看起来像这样:
当我向窗口添加单选按钮或从窗口中删除它们时(通过按“Add C”或“Del A”按钮),窗口会调整大小。
如何防止此行为并创建一个窗口,该窗口可以包含五行单选按钮而不调整大小,并且在删除按钮时不会调整大小。
我的代码:
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)
答案 0 :(得分:1)
使用tkpack.propagate
解决方案很简单。就您而言:
top <- tktoplevel()
tkpack.propagate(top, FALSE)