Dear R-help list members,
I'm writing a package using tcltk. Thanks to Peter Dalgaard's excellent
work on the tcltk package, almost everything has gone very smoothly. I'm
stymied, however, by the following problem:
I want to incorporate a bitmap image, stored as an xbm file, in a widget.
To take a simple example,
top <- tktoplevel()
tkgrid(tklabel(top, bitmap="@file.xbm", fg="red"))
will work as long as file.xbm is in the current directory; alternatively, I
could specify the path to this file. The problem is that I can't figure out
a reliable way of predicting (or discovering) where the bitmap file will
reside when my package is installed.
Any suggestions would be appreciated.
Thanks,
John
-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
bitmap images in tcltk
6 messages · Roger Bivand, John Fox, Dirk Eddelbuettel
On Tue, 6 May 2003, John Fox wrote:
Dear R-help list members,
I'm writing a package using tcltk. Thanks to Peter Dalgaard's excellent
work on the tcltk package, almost everything has gone very smoothly. I'm
stymied, however, by the following problem:
I want to incorporate a bitmap image, stored as an xbm file, in a widget.
To take a simple example,
top <- tktoplevel()
tkgrid(tklabel(top, bitmap="@file.xbm", fg="red"))
will work as long as file.xbm is in the current directory; alternatively, I
could specify the path to this file. The problem is that I can't figure out
a reliable way of predicting (or discovering) where the bitmap file will
reside when my package is installed.
Any suggestions would be appreciated.
system.file(<file path relative to package root>, package="package")[1] should do it.
Thanks, John ----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: jfox at mcmaster.ca phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93 e-mail: Roger.Bivand at nhh.no
On Tue, May 06, 2003 at 02:24:10PM -0400, John Fox wrote:
I'm writing a package using tcltk. Thanks to Peter Dalgaard's excellent work on the tcltk package, almost everything has gone very smoothly. I'm
Seconded. It is truly excellent, and cross-platform without any heachaches.
stymied, however, by the following problem:
I want to incorporate a bitmap image, stored as an xbm file, in a widget.
To take a simple example,
top <- tktoplevel()
tkgrid(tklabel(top, bitmap="@file.xbm", fg="red"))
will work as long as file.xbm is in the current directory; alternatively, I
could specify the path to this file. The problem is that I can't figure out
a reliable way of predicting (or discovering) where the bitmap file will
reside when my package is installed.
Any suggestions would be appreciated.
There is a much easier solution thanks to Luke's tkrplot which is available for win32 and unix on CRAN. A simple example is
tt <- tktoplevel() pl <- tkrplot(tt, function() plot(1:10, main="foo")) tkpack(pl)
It can do fancier stuff too by using a 'replot' feature. The example from
the help page varies a simple function by tieing a callback command and
variable from a scale to a function around tkreplot():
tt <- tktoplevel()
bb<-1
img <-tkrplot(tt, function() plot(1:20,(1:20)^bb))
f<-function(...) {
b <- as.numeric(tclvalue("bb"))
if (b != bb) {
bb <<- b
tkrreplot(img)
}
}
s <- tkscale(tt, command=f, from=0.05, to=2.00, variable="bb",
showvalue=FALSE, resolution=0.05, orient="horiz")
tkpack(img,s)
Dirk
Don't drink and derive. Alcohol and algebra don't mix.
Dear Roger, Thanks -- that's exactly what I needed. I can just stick the files in a bitmaps subdirectory. John
At 08:44 PM 5/6/2003 +0200, you wrote:
On Tue, 6 May 2003, John Fox wrote:
Dear R-help list members,
I'm writing a package using tcltk. Thanks to Peter Dalgaard's excellent
work on the tcltk package, almost everything has gone very smoothly. I'm
stymied, however, by the following problem:
I want to incorporate a bitmap image, stored as an xbm file, in a widget.
To take a simple example,
top <- tktoplevel()
tkgrid(tklabel(top, bitmap="@file.xbm", fg="red"))
will work as long as file.xbm is in the current directory;
alternatively, I
could specify the path to this file. The problem is that I can't figure
out
a reliable way of predicting (or discovering) where the bitmap file will reside when my package is installed. Any suggestions would be appreciated.
system.file(<file path relative to package root>, package="package")[1] should do it.
----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: jfox at mcmaster.ca phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox
Dear Dirk, The tkrplot package is indeed interesting, but my understanding is that it's for putting R graphics in a widget. My bitmaps are for things like button-tops. Perhaps I'm missing something. Regards, John
At 01:53 PM 5/6/2003 -0500, Dirk Eddelbuettel wrote:
On Tue, May 06, 2003 at 02:24:10PM -0400, John Fox wrote:
I'm writing a package using tcltk. Thanks to Peter Dalgaard's excellent work on the tcltk package, almost everything has gone very smoothly. I'm
Seconded. It is truly excellent, and cross-platform without any heachaches.
stymied, however, by the following problem:
I want to incorporate a bitmap image, stored as an xbm file, in a widget.
To take a simple example,
top <- tktoplevel()
tkgrid(tklabel(top, bitmap="@file.xbm", fg="red"))
will work as long as file.xbm is in the current directory;
alternatively, I
could specify the path to this file. The problem is that I can't figure
out
a reliable way of predicting (or discovering) where the bitmap file will reside when my package is installed. Any suggestions would be appreciated.
There is a much easier solution thanks to Luke's tkrplot which is available for win32 and unix on CRAN. A simple example is
tt <- tktoplevel() pl <- tkrplot(tt, function() plot(1:10, main="foo")) tkpack(pl)
It can do fancier stuff too by using a 'replot' feature. The example from
the help page varies a simple function by tieing a callback command and
variable from a scale to a function around tkreplot():
tt <- tktoplevel()
bb<-1
img <-tkrplot(tt, function() plot(1:20,(1:20)^bb))
f<-function(...) {
b <- as.numeric(tclvalue("bb"))
if (b != bb) {
bb <<- b
tkrreplot(img)
}
}
s <- tkscale(tt, command=f, from=0.05, to=2.00, variable="bb",
showvalue=FALSE, resolution=0.05, orient="horiz")
tkpack(img,s)
----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: jfox at mcmaster.ca phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox
On Tue, May 06, 2003 at 04:54:10PM -0400, John Fox wrote:
Dear Dirk, The tkrplot package is indeed interesting, but my understanding is that it's for putting R graphics in a widget. My bitmaps are for things like button-tops. Perhaps I'm missing something.
No, I had misread the question. Sorry, Dirk
Regards, John At 01:53 PM 5/6/2003 -0500, Dirk Eddelbuettel wrote:
On Tue, May 06, 2003 at 02:24:10PM -0400, John Fox wrote:
I'm writing a package using tcltk. Thanks to Peter Dalgaard's excellent work on the tcltk package, almost everything has gone very smoothly. I'm
Seconded. It is truly excellent, and cross-platform without any heachaches.
stymied, however, by the following problem:
I want to incorporate a bitmap image, stored as an xbm file, in a widget.
To take a simple example,
top <- tktoplevel()
tkgrid(tklabel(top, bitmap="@file.xbm", fg="red"))
will work as long as file.xbm is in the current directory;
alternatively, I
could specify the path to this file. The problem is that I can't figure
out
a reliable way of predicting (or discovering) where the bitmap file will reside when my package is installed. Any suggestions would be appreciated.
There is a much easier solution thanks to Luke's tkrplot which is available for win32 and unix on CRAN. A simple example is
tt <- tktoplevel() pl <- tkrplot(tt, function() plot(1:10, main="foo")) tkpack(pl)
It can do fancier stuff too by using a 'replot' feature. The example from
the help page varies a simple function by tieing a callback command and
variable from a scale to a function around tkreplot():
tt <- tktoplevel()
bb<-1
img <-tkrplot(tt, function() plot(1:20,(1:20)^bb))
f<-function(...) {
b <- as.numeric(tclvalue("bb"))
if (b != bb) {
bb <<- b
tkrreplot(img)
}
}
s <- tkscale(tt, command=f, from=0.05, to=2.00, variable="bb",
showvalue=FALSE, resolution=0.05, orient="horiz")
tkpack(img,s)
----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: jfox at mcmaster.ca phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox -----------------------------------------------------
Don't drink and derive. Alcohol and algebra don't mix.