tcl - How do I bring an R Tk window to the front after launching via Rscript from another application? -


i have script along lines of:

if (!require(tcltk2)) {install.packages('tcltk2', repos="http://cran.us.r-project.org"); require(tcltk2)}  base <- null done <- tclvar(0)  quasitelgui <- function(inputfile = null) {     base <- tktoplevel()     tkwm.title(base, "quasitel")      # files     file.frm <- tkframe(base, borderwidth=2)     datafile.lbl <- tklabel(file.frm, text="data")     datafile.entry <- tkentry(file.frm, state="readonly")     datafile.btn <- tkbutton(file.frm, text="browse...")     tkgrid(datafile.lbl, datafile.entry, datafile.btn)     tkgrid.configure(datafile.lbl, sticky="e")     tkgrid.configure(datafile.entry, sticky="ew", padx=1)     tkgrid.columnconfigure(file.frm, 1, weight=1)     tkgrid(file.frm)     tkgrid.configure(file.frm, sticky="ew")      # main     main.frm <- tkframe(base, borderwidth=2)     g1.lbl <- tklabel(main.frm, text="group 1")     g2.lbl <- tklabel(main.frm, text="group 2")     tkgrid(g1.lbl, g2.lbl)      q.btn <- tkbutton(bott.frm, text="quit", command=function() tclvalue(done) <- 1)     tkbind(base,"<destroy>", function() tclvalue(done) <- 2)     tkgrid(filter.lbl, columnspan=2)     tkgrid(filter.entry)     tkgrid(ok.btn, q.btn)     tkgrid.configure(ok.btn, q.btn, padx=1)     tkgrid(bott.frm)     tkgrid.columnconfigure(base, 0, weight=1)      if (length(inputfile) > 0) { datafile.open(inputfile) } }  cmd.args <- commandargs(trailingonly=true)  if (length(cmd.args) > 0) {     quasitelgui(gsub("\\\\", "/", cmd.args[1])) } else {     quasitelgui() }  tkfocus(base) tkwait.variable(done) tkdestroy(base) 

i'm running via rscript gui. want window grab focus when starts. tkfocus doesn't it.

not focus, raise:

> library(tcltk) loading tcl/tk interface ... done > w1 <- tktoplevel() > w2 <- tktoplevel() > tkraise(w1) 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -