rp.image {rpanel} | R Documentation |
An image is placed inside a panel. When the image is clicked the action function is called with the x and y coordinates of the clicked position.
rp.image(panel, filename, action = NA, mousedrag = NA, mouseup = NA, id = "img", parent = window, pos = NULL, ...)
panel |
the panel in which the image should appear. This may be passed as a panelname string or the panel object itself. |
filename |
the name of the file where the image is located. |
action |
the function which is called when the image is clicked. |
mousedrag |
the function which is called when the mouse is dragged. |
mouseup |
the function which is called when the mouse is released. |
id |
the name of the image. |
parent |
this specifies the widget inside which the image should appear. In the current version of rpanel, it should not normally be used. |
pos |
the layout instructions. Please see the |
... |
information for |
The function action
should take three arguments, the panel and the coordinates x and y where the image was clicked. At present only GIF images are supported.
See rp.grid
for details of the grid layout system.
If the parameter panel is the panelname string the same string is returned. If the panel object is used the altered panel is assigned to both the calling level and panel's environment level.
The action
function should return the panel.
Without this assignment any widgets added or alterations made to panel parameters within
the action
function will be lost.
rpanel: Simple interactive controls for R functions using the tcltk package. Journal of Statistical Software, 17, issue 9.
if (interactive()) { gulls.click <- function(panel, x, y) { print(c(x, y)) panel } panel <- rp.control() image.file <- file.path(system.file(package = "rpanel"), "images", "gulllmks.gif") rp.image(panel, image.file, id = "gulls.image", action = gulls.click) }