Hello, everyone. I have the following problem with TclTk: I create some windows and want to change their position with geometry manage (sometimes they will be centered, sometimes not). If the toplevel is created and its dimensions are gathered via 'tkwinfo', I get (usually) correct values. However, if this window is created by a function (in the following example, by 'ask.format') and this function is called by another function ('inputDialog', as follows), I always get the value '1' for width and height.
Provided below is quite detailed code, containing pretty much my entire functions, except the parts not related to TclTk. Thank you in advance, Gabriel Margarido. CODE: library(tcltk) ask.format <- function() { ask.form <- tktoplevel() tkgrab.set(ask.form) tkfocus(ask.form) tkwm.title(ask.form,"Input Format") tkwm.resizable(ask.form, 0, 0) file.format <- tclVar("1") ReturnFormat <- "ID_CANCEL" Title.frame <- tkframe(ask.form, relief="groove") tkgrid(tklabel(Title.frame,text="Input File Format", font="Times 15", foreground="dark red")) tkgrid(Title.frame) Choose.frame <- tkframe(ask.form, relief="groove", borderwidth=2) file.format1 <- tkradiobutton(Choose.frame) file.format2 <- tkradiobutton(Choose.frame) tkconfigure(file.format1, variable=file.format, value="1") tkconfigure(file.format2, variable=file.format, value="2") tkgrid(tklabel(Choose.frame, text="Format 1 "),file.format1) tkgrid(tklabel(Choose.frame, text="Format 2 "),file.format2) tkgrid(Choose.frame) onOK <- function() { ReturnFormat <<- tclvalue(file.format) tkgrab.release(ask.form) tkdestroy(ask.form) } onCancel <- function() { tkgrab.release(ask.form) tkdestroy(ask.form) } Buttons.frame <- tkframe(ask.form, relief="groove") OK.but <- tkbutton(Buttons.frame, text = " OK ", command = onOK) cancel.but <- tkbutton(Buttons.frame, text = "Cancel", command = onCancel) tkgrid(cancel.but, OK.but, ipadx=20) tkgrid(Buttons.frame) print(as.integer(tclvalue(tkwinfo("height", ask.form)))) tkbind(ask.form, "<Destroy>", function() onCancel) tkbind(ask.form, "<KeyPress-Return>", onOK) tkbind(ask.form, "<KeyPress-Escape>", onCancel) tkwait.window(ask.form) return(ReturnFormat) } inputDialog <- function() { input <- tktoplevel(background="white") tkgrab.set(input) tkfocus(input) tkwm.title(input, "Data Input") tkwm.resizable(input, 0, 0) OpenVal <- c(0,0) getfile <- function() { ### HERE I WOULD ALSO LOAD THE INPUT FILE, BUT THIS IS NOT RELEVANT inputformat <- ask.format() if (inputformat == "ID_CANCEL") return() OpenVal[1] <<- 1 tkgrab.release(input) tkdestroy(input) } tkgrid(tklabel(input, text = "Choose an input file",background="white",font="Times 13"),columnspan=3) button.file <- tkbutton(input, text = "Open Input Data File", command = getfile) button.exit <- tkbutton(input, text = "Exit", command = function() {tkdestroy(input); OpenVal[2] <<- 1}) tkgrid(button.file, button.exit) tkfocus(input) tkbind(input, "<Destroy>", function() {tkgrab.release(input); OpenVal[2] <<- 1}) tkwait.window(input) return(OpenVal) } ask.format() ## this works, although with some variation in values inputDialog() ## window size is always 1 [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.