guiFrame: Various Graphical Widgets

Description Usage Arguments Details Examples

View source: R/widgets.R

Description

Creates various graphical objects, used internally by the ‘gui’ routine, but exported in case useful and as examples of further customization. Try getFromNamespace and assignInNamespace to fully customize these routines in your own code. Documentation in tcltk may also help.

guiFrame creates a frame.

guiTextEntry creates a short one-line text entry.

guiSlider creates a slider with a range of values to choose, useful for power calcs.

guiFilename provides a means to get filenames.

guiOption allows a choice of options.

guiList allows a choice of greater options, which can be modified later. setListElements and getSelectedListElements are routines to dynamically set these lists and get the selected elements.

guiEdit is an edit box.

helpButton creates a helpButton.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
guiFrame( sframe, grid=FALSE, relief="groove",
           borderwidth=2, sticky="nws" )

guiTextEntry( sframe, text, default, width=NULL, helps=NULL )
guiSlider( sframe, text, default, min, max, step=(max-min)/100,
            update=NULL, state="enabled", helps=NULL )
guiFilename( sframe, text="Filename ...", default="", title="",
              filter="{{All files} {.*}}", callback=NULL, helps=NULL )
guiOption( sframe, text, choices, defaultChoice=1,
            update=NULL, helps=NULL )
guiList( sframe, text, name=text, update=NULL, helps=NULL )
guiEdit( sframe, text="", default="", width=NULL, height=NULL,
          readonly=FALSE, helps=NULL )
helpButton( sframe, helps, title )

getSelectedListElements( name )
setListElements( name, elements )

Arguments

sframe

The tkframe to grid upon.

grid

Whether the object should be gridded or not. Default is FALSE, so user can grid objects together.

relief

tkframe option

borderwidth

tkframe option

sticky

Combination of ‘nwes’ for stickiness of object.

text

The text of the object, to describe it to the user.

default

Default value for an object.

min

min of slider range

max

max of slider range

step

stepsize of slider range

update

function to send callbacks to, should take one argument (see examples in 'gui' routine)

state

e.g. ‘readonly’, see tcltk docs

helps

An optional string of help to be given when a user clicks the ‘?’ button to provide more information. If NULL, no such button is drawn.

title

Title for the window.

filter

File filter, see examples in 'gui' for the form.

callback

Callback function. For command function, both ‘callback’ and ‘update’ functions are performed.

choices

List of possible choices.

defaultChoice

Default choice to choose, the numeric index to this.

name

Identifier.

width

Width of the edit box.

height

Height of the edit box.

readonly

Whether to create in readonly state.

elements

Array of strings for the list elements.

Details

tkFrame and helpButton return the tcltk object reference.

The other routines return a list. The first object, object, is either a tclVar or the string ‘no object’ for things like command buttons where this does not make sense (use main<-tktoplevel(); res<-tkFrame(main); tclvalue(res$object), e.g., to get the value). The second object, guiObject returns a reference to the tcltk frame gui the object is contained in for gridding purposes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Not run: 
## Create a form with tcltk routines
main <- tktoplevel()
## Create some widgets for that form
## - Create a frame, and put two widgets in it
## - Note that guiTextEntry objects will be gridded automatically
##   (which is why as an example they are put in a frame)
fr <- guiFrame( sframe=main )
te1 <- guiTextEntry( sframe=fr, text="Text entry 1", default="default" )
te2 <- guiTextEntry( sframe=fr, text="Text entry 2", default="" )
## - Put the rest of the widgets on the main frame
sl <- guiSlider( sframe=main, text="Slider", default=5, min=1, max=10 )
fl <- guiFilename( sframe=main, text="Filename", default="foo.txt" )
op <- guiOption( sframe=main, text="Option", choices=c("one","two","three") )
ed <- guiEdit( sframe=main, text="Edit", default="Edit box" )
## Now grid the widgets on the main form
tkgrid( fr )
tkgrid.configure( fr, sticky="nws" ) ## Handle alignment, as in tcl/tk package
tkgrid( sl$guiObject )
tkgrid( fl$guiObject )
tkgrid( op$guiObject )
tkgrid( ed$guiObject )
print( tclvalue(fl$object) ) ## will print out "foo.txt", unless modified

## End(Not run)

fgui documentation built on May 2, 2019, 3:37 p.m.

Related to guiFrame in fgui...