rp.image: Placement of an image within a rpanel

View source: R/image.r

rp.imageR Documentation

Placement of an image within a rpanel

Description

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.

Usage

rp.image(panel, filename, imagename, action=NA, mousedrag=NA, mouseup=NA, pos=NULL,
  parentname=deparse(substitute(panel)), ...) 

Arguments

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.

imagename

name assigned to the image, used for disposing of the widget

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.

pos

the layout instructions. Please see the rp.pos example and help for full details.

parentname

this specifies the widget inside which the image should appear.

...

...

Details

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.

Value

If the argument 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.

Warning

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.

Note

The former arguments parent and ... have been discontinued in version 1.1. Note also that the argument id has been renamed name to be consistent with the rest of rpanel.

References

rpanel: Simple interactive controls for R functions using the tcltk package. Journal of Statistical Software, 17, issue 9.

Examples

## Not run: 
   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, gulls.image, action = gulls.click)

## End(Not run)

rpanel documentation built on Feb. 16, 2023, 10:37 p.m.

Related to rp.image in rpanel...