tcl - In R tcltk, how to check whether a widget exists and replace it if it does? -
i'm working on tcltk interface in r creates set of drop down combo boxes based on fields in whichever dataset loaded user. right have button ("getbox") press after loading data reads data creates combo box option each field. i'd able re-create combo box each time press button instead of adding new combo box. here example of have:
tt <- tktoplevel() comboframe <- tkframe(tt) getbox <- tkbutton(tt, text = "create combo box", command = function() { fields <- names(mtcars) cbox <- tkwidget(comboframe, "combobox", editable = false, values = fields) tkgrid(cbox) }) tkgrid(getbox) tkgrid(comboframe) i tried adding if statement in getbox command function, couldn't work.
if (exists(comboframe)) { tkdestroy(comboframe) } # create combobox ... any thoughts on how replace combo box instead of adding new one? thanks!
Comments
Post a Comment