简体   繁体   中英

How to hide TclTk window in R while it is being drawn

TclTk is working fine in R, it's just that I can see the widgets being placed on the window as it is being built. Is there a way to hide the window, and only show it once it is built? Paste the following into R and you'll see the window filling up. That's what I don't want user to see (if possible). Thanks.

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)

I have the following pattern in gWidgetstcltk:

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

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

You can just wrap the whole thing in curly braces. That's worked for me so far.

Something like:

{ # Begin building window
  (code)
} # End building window

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