rp.pos: Positioning controls in an rpanel

View source: R/pos.r

rp.posR Documentation

Positioning controls in an rpanel

Description

This function provides demonstrations of the use of the pos argument in functions to create controls.

Usage

rp.pos(layout="default")

Arguments

layout

the type of panel layout to be demonstrated. Valid options are "default", "pack", "place" and "grid".

Details

The various functions to create controls accept a parameter called pos which can be used to specify the layout of the controls. It has various modes of operation and the mode is determined from the type of information provided in the pos argument. The different modes are outlined below.

  • default If pos is not specified, controls are arranged in a column with the most recent added to the bottom. Each control is aligned to the left hand side.

  • pack if pos is set to "left", "right", "top" or "bottom", then the control is set to the left, right, top or bottom edge of the panel. If there is already a control in that position, the new control is placed beside that control, closer to the centre. (This uses Tk's "pack" layout manager.)

  • place If pos is set to a vector of four integer values, these are interpreted as (x, y, width, height) where all dimensions are in pixels. x and y define the co-ordinates in from the left hand side and down from the top respectively. When using this mode of laying out objects, it usually helps to define the size of the panel in rp.control. (This uses Tk's "place" layout manager.)

  • grid This mode provides greater flexibility in layout. The following arguments can be passed to pos in any of the function calls to create controls. Alternatively, pos can be passed a list which has these named components.

    • columnAn integer which specifies the column number. Columns count from 0. This is a mandatory field for grids.

    • rowAn integer which specifies the row number. Rows count from 0. This is a mandatory field for grids.

    • gridA string which gives the name of the grid the control has to be placed in. This field is optional. If omitted the default grid belonging to the panel is used.

    • columnspanAn integer which specifies how many columns the control should span. Columns are counted to the right from the start column specified by column. This field is optional. If omitted one column is assumed.

    • rowspanAn integer which specifies how many rows the control should span. Rows are counted down from the start row specified by row. This field is optional. If omitted one row is assumed.

    • widthAn integer which specifies the width of the control. For controls with writing (buttons, listboxes etc) this is in characters and for images this is in pixels. This field is optional. If omitted the control is sized horizontally to fill the cell the control is placed within.

    • heightAn integer which specifies the height of the control. For controls with writing (buttons, listboxes etc) this is in characters and for images this is in pixels. This field is optional. If omitted the control is sized vertically to fill the cell the control is placed within.

    • stickyAn string which specifies how the control expands to fill the cell. This is a string with any combination of 'n', 'e', 'w', 's', representing north/east/west/south expansions. An empty string assignment (”) will centre the control. If the argument is not assigned a value then the control is 'w' (west) aligned by default.

    • backgroundSpecifies the background colour of the grid. If left blank this defaults to the operating system's standard background colour.

    (This uses Tk's "grid" layout manager.)

    The "grid" mode of layout should not be mixed with the other modes.

The example below illustrates the use of pos. Try resizing the windows to explore the behaviour.


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

Related to rp.pos in rpanel...