Hello,
the admonition of Prof. Ripley to search the documentation to solve my problem
helped, today I read a lot more on Tcl/Tk than before ;-)
But now I'm stuck again. With the help of my script some functions are
plotted
on the display, then I ask if the user wants to save it as pdf. In windows I
use winDialog and it works. But I can't succeed in Linux. In short:
----------------------------------------------------
X11()
...
res <- tkmessageBox(title="Beenden?",
message="Vor dem Beenden als PDF speichern?",
icon="question", type="okcancel")
if (tclvalue(res) == "ok")
...
-----------------------------------------------------
So far every thing is OK. Now I want a box the user should fill in the choosen
filename (with a default)
and then
--------------------
pdf(filename)
...
--------------------
I experimented with tkgetSaveFile(). But in the moment the user gives the
filename the file is not yet generated! And I can't generate it in advance,
because the filename is not yet specified.
So I looked for a dialog box. [Some boxes are called "dialog boxes"
though
they only talk _to_ the user (besides the user's "yes" or
"no")]. Just a
simple box with a text field the user can type in and the value of this field
given back.
One option was the "modal dialog", but I was not able to pick the
essentials
out of it. I did not want to press several buttons until the necessary window
appears. Also the "editable text window" was not really a solution.
Perhaps a small hint again?
Richard
--
Richard M?ller - Am Spring 9 - D-58802 Balve-Eisborn
www.oeko-sorpe.de
Richard M?ller wrote:> Hello, > the admonition of Prof. Ripley to search the documentation to solve my problem > helped, today I read a lot more on Tcl/Tk than before ;-) > But now I'm stuck again. With the help of my script some functions are plotted > on the display, then I ask if the user wants to save it as pdf. In windows I > use winDialog and it works. But I can't succeed in Linux. In short: > ---------------------------------------------------- > X11() > ... > res <- tkmessageBox(title="Beenden?", > message="Vor dem Beenden als PDF speichern?", > icon="question", type="okcancel") > if (tclvalue(res) == "ok") > ... > ----------------------------------------------------- > So far every thing is OK. Now I want a box the user should fill in the choosen > filename (with a default) > and then > -------------------- > pdf(filename) > ... > -------------------- > I experimented with tkgetSaveFile(). But in the moment the user gives the > filename the file is not yet generated! And I can't generate it in advance, > because the filename is not yet specified. >I don't see what the problem is here. fn <- tkgetSaveFile() allows you to select an existing file OR navigate to a directory and type in the name of a new file. In either case, you can feed tclvalue(fn) to pdf(). If you cancel the operation, then tclvalue(fn)=="", so test for that first.> So I looked for a dialog box. [Some boxes are called "dialog boxes" though > they only talk _to_ the user (besides the user's "yes" or "no")]. Just a > simple box with a text field the user can type in and the value of this field > given back. > One option was the "modal dialog", but I was not able to pick the essentials > out of it. I did not want to press several buttons until the necessary window > appears. Also the "editable text window" was not really a solution. > Perhaps a small hint again? > Richard > >-- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
> > ... > > I experimented with tkgetSaveFile(). But in the moment the user > > gives the > > filename the file is not yet generated! And I can't generate it in > > advance, > > because the filename is not yet specified. > > I don't see why this is a problem. In tkgetSaveFile(), the user can > just navigate to the correct directory and then type a filename in. > Then that would be returned. The following worked over here: > > x<-tkgetSaveFile() > #.. go to right directory and type in filename > tclvalue(x)Thank you, Charilaos, for your posting. I wrote the following: -------------------------------------------------- require(tcltk) #Tcl/Tk - Texteingabe Datei <- tkgetSaveFile(initialdir="temp/",defaultextension=".pdf", initialfile="Haupt_Chl_ Phaeo.pdf") fileName <- tclvalue(Datei) pdf(fileName) # graphical device driver with filename ...(code for the graphics)... --------------------------------------------------- As expected, I get an empty pdf-file. Specifying the pdf-device-driver results in automatically saving the generated pdf. The tkGetSave-function isn't helpful in this case. I must have the possibility to input a filename and then give this filename as an argument to the device-driver. Richard -- Richard M?ller - Am Spring 9 - D-58802 Balve-Eisborn www.oeko-sorpe.de
Oops, I just sent the wrong mail. It should be the following one. Please
delete my mail from 30.Dez. 17:51
Sorry, but I don't really understand the recommended method using the tk-Box
"tkGetSaveFile".
I wrote the following code:
X11()
# some code to generate a plot on the screen omitted
res <- tkmessageBox(title="Finish?",
message="save as PDF?",
icon="question", type="okcancel")
if (tclvalue(res) == "ok")
Datei <-
tkgetSaveFile(initialdir="temp/",defaultextension=".pdf",
initialfile="Haupt_Chl_Phaeo.pdf")
dev.copy(pdf, tclvalue(Datei))
else graphics.off()
graphics.off()
In the moment I'm saving I dont have the pdf generated yet. If I put it the
other way round:
dev.copy(pdf, tclvalue(Datei))
if (tclvalue(res) == "ok")
Datei <-
tkgetSaveFile(initialdir="temp/",defaultextension=".pdf",
initialfile="Haupt_Chl_Phaeo.pdf")
I don't have the filename specified when it is needed.
(But today I could finish the Windows versions at last, using WinDialog ;-)
Greetings
Richard
--
Richard M?ller - Am Spring 9 - D-58802 Balve-Eisborn
www.oeko-sorpe.de