How to hide TclTk window in R while drawing it

TclTk works fine in R, I just see that widgets are placed in the window as it is created. Is there a way to hide the window and show it only after it is created? Paste the following into R and you will see the window fill up. This is what I do not want the user to see (if possible). Thank.

require(tcltk)
dlg = tktoplevel()
# command to hide window ?
for (i in 1:10) {
    l = list()
    for (i in 1:20) l[[i]]=tkbutton(dlg,text="SO")
    do.call(tkgrid,l)
}
# command to show window now it is built ?
tkwait.window(dlg)
tkdestroy(dlg)
+3
source share
2 answers

I have the following template in gWidgetstcltk:

library(tcltk)
tclServiceMode(FALSE)
win <- tktoplevel()
tkwm.state(win,"withdrawn") 
tclServiceMode(TRUE)

## ... do your thing then:
tkwm.state(win,"normal")
+4
source

You can simply wrap all curly braces. This has been valid for me so far.

Sort of:

{ # Begin building window
  (code)
} # End building window
+2
source

All Articles