Displaying an image in a Tk widget.

The following code displays the file "logo.jpg" in a Tk window (actually in a Tk label widget within a Tk window). The "Img" package is not included in the minimal Tcl/Tk installation that comes with R, but it can be found by downloading ActiveTcl. The source is available at http://www.xs4all.nl/~nijtmans/img.html.

R.base.dir <- system.file()
setwd(paste(R.base.dir,"/../../doc/html",sep=""))
require(tcltk)
tt <- tktoplevel()
tclRequire("Img")
image1 <- tclVar()
tkcmd("image","create","photo",image1,file="logo.jpg")
imgAsLabel <- tklabel(tt,image=image1,bg="white")
tkpack(imgAsLabel)