Title: | Rewrite of gWidgets API for Simplified GUI Construction |
---|---|
Description: | Re-implementation of the 'gWidgets' API. The API is defined in this package. A second, toolkit-specific package is required to use it. At this point only 'gWidgets2tcltk' is viable. |
Authors: | John Verzani [aut, cre] |
Maintainer: | John Verzani <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.0-10 |
Built: | 2024-12-07 20:31:00 UTC |
Source: | CRAN |
The gWidgets2 package provides a programming interface for
making graphical user interfaces within R. The package is a
rewrite of the gWidgets package, introducing a few external
changes but a significant number of internal ones. The package
relies on one of several underlying toolkit packages providing
access to the graphical libraries. These will include RGtk2,
tcltk, qtbase, and a collection of browser widgets
provided by ExtJS
. As of now, only gWidgets2RGtk2 is
near completion.
The package provides constructors to produce controls, the widgets that a user interacts with; containers, GUI objects used to organize the controls within a window; and dialogs, simple one-off windows for gathering quick user feedback. These objects are manipulated through various methods. The package provides a few new generics and, as much as possible, leverages existing methods for R.
Controls are created by constructors. The package API includes the following. As much as possible these are implemented in the toolkit packages, but there may be instances where that is not possible.
gbutton
Provides a basic button to initiate an action
gcalendar
Provides a text entry area with selector for a date
gcheckbox
Provides a labeled checkbox to allow a user to toggle a selection
gcheckboxgroup
Provides a collection of checkboxes allowing selection or 0, 1, or several from many items
gcombobox
Provides a drop down list of choices to select from and possible and entry area for free response
gdf
Provides a data frame editing widget
gedit
Provides a single line text entry widget
ggraphics
Provides an embeddable graphic device
gimage
Provides a widget to hold images
glabel
Provides a widget to hold labels for other controls
gmenu
Provides menus for top-level windows and popup menus
gradio
Provides a means to select one of many items
gseparator
Provides a visual line to separate off parts of a window
gslider
Provides a means to select one value from a (seeming) continuum of values
gspinbutton
Provides means to select a value from s sequence of values
gstatusbar
Provides a widget to display status messages in a top-level window
gtable
Provides a widget to display tabular data for selection
gtext
Provides a multiline text-editing widget
gtimer
Provides a one-shot or repeatable timer
gtoolbar
Provides toolbars for top-level windows
gtree
Provides a display for heirarchicial data
gvarbrowser
Provides a widget showing a shapshot of the current global workspace
gaction
Provides a means to encapsulate actions for use with menu bars, tool bars and buttons.
Containers are used to organize controls with a window. The package provides the following:
gexpandgroup
Provides a container with an option to disclose or hide its children
gframe
Provides a framed box container
ggroup
Provides a horizontal or vertical box container for packing in child components
glayout
Provides a container to organize data by row and column cell
gnotebook
Provides a notebook container
gpanedgroup
Provides a divided container with adjustable divider
gstackwidget
Provides a container like a notebook, but without tab labels
gwindow
Provides a top-level window
Dialogs in gWidgets2 are typically modal, meaning they block input to any other window and the R process. They do not return objects to be manipulated through methods, but rather return values selected by the user.
gmessage
Produces a simple dialog to display a message
gconfirm
Produces a dialog for a user to confirm an action
ginput
Provides a dialog to gather user in=put
gbasicdialog
Provides a means to produce general modal dialogs
galert
Provides a short transient message dialog
gfile
Provides a dialog to select a filename or directory name
Except for dialogs, the constructors produce objects for which
several methods are defined that allow the programmer access to
getting and setting of the object state. For the most part these
are S3 methods. The actual returned object is a reference class
instance, as provided by an underlying toolkit. These may have
toolkit-specific methods defined as reference class methods (i.e.,
call them using $meth_name
). Any such methods are
documented in the toolkit packages.
svalue
, svalue<-
The main new method. This is used to retrieve or set the main property associated with a widget
enabled
, enabled<-
A widget is enabled if it is sensitive to user input. Non-enabled widgets typically are rendered in a greyed out state.
visible
, visible<-
The generic idea of a visible widget is one that is drawn. However, several classes override this to mean part of the widget is visible or not visible.
focus
, focus<-
A widget with focus receives any keyboard input.
editable
, editable<-
A widget is editable if it can receive keyboard input.
font
, font<-
The font for an object is specifed through this method using a convention illustrated in the help page.
size
, size<-
The size of a widget is retrieved or requested through these methods
tooltip
, tooltip<-
A tooltip provides contextual information when a mouse hovers over an object
undo
, redo
Some widgets support an undo and redo stack
isExtant
A method to check if the GUI part of a widget still exists. (A constructor produces an R object and GUI object through the toolkit.)
tag
, tag<-
A method used to set attributes for an object that are stored in an environment so that they are passed by reference, not copy. This allows event handlers to manipulate an object's attributes outside the scope of the callback.
getToolkitWidget
Returns the underlying toolkit object that is packaged into a gWidgets2 object
add
Method used to add a child component to a parent container
delete
Method used to delete a component from its parent
dispose
Method used to delete a component
The package overloads some familar R methods.
length
, length<-
Returns the length of an object, typically related to the number of children a container has, or the length of the items that a user can selection from.
dim
Used to return row and column size information as applicable.
names
, names<-
Used to set the names associated to an object. These may be column names in the table widget, or tab names in the notebook container.
dimnames
, dimnames<-
Used to set row and column names, as applicable.
[
, [<-
Used to update the underlying items
that a selection widget offers. Also used to specify layout in
glayout
update
Call to update the state of a widget, when applicable.
Graphical User Interfaces are made interactive by assigning a
function (a callback) to be called when some event happens. In
gWidgets2 the addHandlerXXX
methods are defined to
assign this callback to a type of event specified through the
XXX
, detailed below. The generic addHandlerChanged
is the most common event for a widget. This event can also have a
handler specified through the handler
argument of the
widget constructor.
In gWidgets2 handlers are functions which when called are
passed a list as the first argument, and possibly toolkit-specific
arguments for subsequent arguments. As such the signature
typically looks like (h,...)
, where the list h
has
components obj
, containing a reference to the widget
emitting the event and action
passing in any information
specified to the action
argument. Some events also pass
back extra information, such as x
and y
for
position, or key
for key events, as appropriate.
addHandlerChanged
Assigns callback for the most generic event
addHandlerClicked
Assigns callback for a mouse click event
addHandlerDoubleclick
Assigns callback for a mouse double-click event
addHandlerRightclick
Assigns callback for a mouse right-click event
addHandlerColumnclicked
Assigns callback for a column-click event
addHandlerColumnDoubleclicked
Assigns callback for a column-double-click event
addHandlerColumnRightclicked
Assigns callback for a column-right-click event
addHandlerSelect
Assigns callback when the underlying selection is changed
addHandlerFocus
Assigns a callback for when a widget receives focus
addHandlerBlur
Assigns a callback for when a widget loses focus
addHandlerDestroy
Assigns a callback for when a widget is destroyed
addHandlerUnrealize
For gwindow
this
is called before the destroy event and may stop that from
happening.
addHandlerExpose
Assigns callback to be called when a widget is exposed
addHandlerKeystroke
Assigns callback to be called when a key event occurs
addHandlerMouseMotion
Assigns callback to be called when a mouse moves over a widget
addHandler
Base method to add a callback though rarely called, as it is toolkit specific
addHandlerIdle
Assign a callback to be called
at periodic intervals. See also gtimer
addPopupMenu
Add a popup menu
addRightclickPopupMenu
Add a popup menu for the right mouse (context menu)
addDropSource
Specify widget as a source (drag area) for drag and drop
addDropTarget
Specify widget as a target (drop area) for drag and drop
addDragMotion
Assign callback for event that a drag event crosses a widget
blockHandlers
, blockHandler
Block all handlers for a widget (or by single ID)
unblockHandlers
, unblockHandler
Unblock any blocked handlers (or by single ID)
removeHandler
Remove a handler by it ID
John Verzani [email protected]
Maintainer: John Verzani [email protected]
Toolkit constructor
## Default S3 method: .gdfnotebook(toolkit, items, container = NULL, ...)
## Default S3 method: .gdfnotebook(toolkit, items, container = NULL, ...)
toolkit |
toolkit |
items |
data frame for initial page, when given |
container |
parent container |
... |
passed to |
Names are used in many different contexts.
We use the extraction operator, [
, typically to refer to
the underlying items from which a selection can be made. As well,
we overload this to containers to refer to the child components.
The update method will ca use a widget to recompute itself, if it is necessary.
The current items for a gdf
object are both the visible and
non-visible items. To retrieve just the currently visible items,
use the idiom obj[visible(obj), ]
.
The underlying widget may allow autocompletion, if this is the case then this method is used to set the list of candidates.
## S3 method for class 'GDefaultWidget' x[i, j, ...] ## S3 method for class 'GComponent' length(x) ## S3 replacement method for class 'GComponent' length(x) <- value ## S3 method for class 'GComponent' dim(x) ## S3 method for class 'GComponent' names(x) ## S3 replacement method for class 'GComponent' names(x) <- value ## S3 method for class 'GComponent' dimnames(x) ## S3 replacement method for class 'GComponent' dimnames(x) <- value ## S3 method for class 'GComponent' x[i, j, ..., drop = TRUE] ## S3 method for class 'GContainer' x[i, j, ..., drop = TRUE] ## S3 replacement method for class 'GComponent' x[i, j, ...] <- value ## S3 method for class 'GComponent' update(object, ...) ## S3 method for class 'GComponent' str(object, ...) ## S3 method for class 'GDf' x[i, j, ..., drop = TRUE] ## S3 method for class 'GEdit' x[i, j, ..., drop = TRUE] ## S3 replacement method for class 'GFrame' names(x) <- value
## S3 method for class 'GDefaultWidget' x[i, j, ...] ## S3 method for class 'GComponent' length(x) ## S3 replacement method for class 'GComponent' length(x) <- value ## S3 method for class 'GComponent' dim(x) ## S3 method for class 'GComponent' names(x) ## S3 replacement method for class 'GComponent' names(x) <- value ## S3 method for class 'GComponent' dimnames(x) ## S3 replacement method for class 'GComponent' dimnames(x) <- value ## S3 method for class 'GComponent' x[i, j, ..., drop = TRUE] ## S3 method for class 'GContainer' x[i, j, ..., drop = TRUE] ## S3 replacement method for class 'GComponent' x[i, j, ...] <- value ## S3 method for class 'GComponent' update(object, ...) ## S3 method for class 'GComponent' str(object, ...) ## S3 method for class 'GDf' x[i, j, ..., drop = TRUE] ## S3 method for class 'GEdit' x[i, j, ..., drop = TRUE] ## S3 replacement method for class 'GFrame' names(x) <- value
x |
component |
i |
index or row index if applicable |
j |
column index if applicable |
... |
dots argument |
value |
value to assign |
drop |
logical. Does return value get "dropped" down to something easier? |
object |
object to update |
length of object
Add packs in child objects.
Delete may or may not remove a child. This is toolkit specific. It may also be tied up with garbage collection. To avoid that, keep a reference to the child object before deleting.
add(obj, child, expand = FALSE, fill = NULL, anchor = NULL, ...) ## Default S3 method: add(obj, child, expand = FALSE, fill = NULL, anchor = NULL, ...) delete(obj, child) ## S3 method for class 'GContainer' delete(obj, child)
add(obj, child, expand = FALSE, fill = NULL, anchor = NULL, ...) ## Default S3 method: add(obj, child, expand = FALSE, fill = NULL, anchor = NULL, ...) delete(obj, child) ## S3 method for class 'GContainer' delete(obj, child)
obj |
parent object |
child |
child widget |
expand |
NULL or logical. For box containers controls whether a child will expand to fill the allocated space. |
fill |
NULL or character. For box containers. The value of |
anchor |
NULL or integer. For box containers. The anchor argument is used to position the child within the parent when there is more space allocated than the child requests. This is specified with a Cartesian pair in {-1,0,1} x {-1, 0, 1}. |
... |
passed on to the |
The change handler for ggraphics is called when a rubber-band selection is completed
The click handler is called on a mouse click. The handler object should pass in value for x
, y
A GUI is made interactive by assigning handlers to user-generated
events, such as a mouse click, change of widget state, or keyboard
press. In gWidgets2 handlers are assigned through various
addHandlerXXX
methods. The handlers are functions whose
first argument should expect a list with components obj
(to
pass in the receiver object) and action
(to pass in any
user-supplied value to the action
argument). Some handlers
add other components, such as mouse position information on a
click, or key information on a keyboard event.
The "changed" event varies wildly amongst the widgets, but is meant to be the most "obvious" one. Typically this is also similar to "selected".
This may not be supported by all toolkits.
This may not be supported by all toolkits.
This may not be supported by all toolkits.
For table widgets (gtable
, gdf
) clicking the column
header should trigger this event. The column that is clicked on is
passed back in the component column
.
If defined (gtable
, gdf
) calls event handler for
double click enent. Passes back column information through
column
component.
The select event defaults to the "changed" event.
The "select" event is when a user "selects" an object, the "selection changed" event is when the selection changes. The distinction is in table and tree widgets where a user may select values with a single click yet want to initiate an action with a double click. The latter is the "addHandlerSelect" event, the former the "addHandlerSelectionChanged" event.
When a widget has the focus, it will receive the keyboard input. This handler is called when a widget receives the focus.
A blur or focus out event for a widget triggers this event handler
When a widget is destroyed, a handler can be assigned to perform any clean up tasks that are needed.
For gwindow objects this handler is called before the window is
closed. If this handler returns TRUE
the window will be
closed, if FALSE
the window will not be closed. In
contrast, the "destroy" handler does not allow conditional
destruction.
The "h" argument has components key
for the key and possibly modifier
for the modifier.
deprecated. See gtimer
.
Defaults to adding a right-click mouse popup menu, better known as a context menu, though some toolkits have both this and the latter provided.
These menus are also known as context menus, though there isn't really a good mechanism within gWidgets2 to make the menu items context sensitive.
Drag and drop requires one to register widgets a sources for dragging, a widgets as a targets for dropping.
The handler is called on the drop event. The component
dropdata
passes in the value being transferred by dragging.
Block all handlers for an object. Removed via unblockHandlers.
The block is a counter that gets decremented. If more blockHandlers calls are made than unblockHandlers, the handlers will still be blocked.
## Default S3 method: addHandlerChanged(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerClicked(obj, handler, action = NULL, ...) addHandler(obj, signal, handler, action = NULL, ...) ## Default S3 method: addHandler(obj, signal, handler, action = NULL, ...) addHandlerChanged(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerChanged(obj, handler, action = NULL, ...) addHandlerClicked(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerClicked(obj, handler, action = NULL, ...) addHandlerDoubleclick(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerDoubleclick(obj, handler, action = NULL, ...) addHandlerRightclick(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerRightclick(obj, handler, action = NULL, ...) addHandlerShiftclick(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerShiftclick(obj, handler, action = NULL, ...) addHandlerControlclick(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerControlclick(obj, handler, action = NULL, ...) addHandlerColumnclicked(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerColumnclicked(obj, handler, action = NULL, ...) addHandlerColumnDoubleclicked(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerColumnDoubleclicked(obj, handler, action = NULL, ...) addHandlerColumnRightclicked(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerColumnRightclicked(obj, handler, action = NULL, ...) addHandlerSelect(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerSelect(obj, handler, action = NULL, ...) addHandlerSelectionChanged(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerSelectionChanged(obj, handler, action = NULL, ...) addHandlerFocus(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerFocus(obj, handler, action = NULL, ...) addHandlerBlur(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerBlur(obj, handler, action = NULL, ...) addHandlerDestroy(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerDestroy(obj, handler, action = NULL, ...) addHandlerUnrealize(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerUnrealize(obj, handler, action = NULL, ...) addHandlerExpose(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerExpose(obj, handler, action = NULL, ...) addHandlerKeystroke(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerKeystroke(obj, handler, action = NULL, ...) addHandlerMouseMotion(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerMouseMotion(obj, handler, action = NULL, ...) addHandlerIdle(...) addPopupMenu(obj, menulist, action = NULL, ...) ## Default S3 method: addPopupMenu(obj, menulist, action = NULL, ...) addRightclickPopupMenu(obj, menulist, action = NULL, ...) ## Default S3 method: addRightclickPopupMenu(obj, menulist, action = NULL, ...) ## Default S3 method: addRightclickPopupMenu(obj, menulist, action = NULL, ...) ## Default S3 method: addRightclickPopupMenu(obj, menulist, action = NULL, ...) addDropSource( obj, handler, action = NULL, data.type = c("text", "object"), ... ) ## Default S3 method: addDropSource( obj, handler, action = NULL, data.type = c("text", "object"), ... ) addDropTarget(obj, handler, action = NULL, ...) ## Default S3 method: addDropTarget(obj, handler, action = NULL, ...) addDragMotion(obj, handler, action = NULL, ...) ## Default S3 method: addDragMotion(obj, handler, action = NULL, ...) blockHandlers(obj, ...) ## Default S3 method: blockHandlers(obj, ...) blockHandler(obj, ID, ...) ## Default S3 method: blockHandler(obj, ID, ...) unblockHandlers(obj, ...) ## Default S3 method: unblockHandlers(obj, ...) unblockHandler(obj, ID, ...) ## Default S3 method: unblockHandler(obj, ID, ...) removeHandler(obj, ID, ...) ## Default S3 method: removeHandler(obj, ID, ...)
## Default S3 method: addHandlerChanged(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerClicked(obj, handler, action = NULL, ...) addHandler(obj, signal, handler, action = NULL, ...) ## Default S3 method: addHandler(obj, signal, handler, action = NULL, ...) addHandlerChanged(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerChanged(obj, handler, action = NULL, ...) addHandlerClicked(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerClicked(obj, handler, action = NULL, ...) addHandlerDoubleclick(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerDoubleclick(obj, handler, action = NULL, ...) addHandlerRightclick(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerRightclick(obj, handler, action = NULL, ...) addHandlerShiftclick(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerShiftclick(obj, handler, action = NULL, ...) addHandlerControlclick(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerControlclick(obj, handler, action = NULL, ...) addHandlerColumnclicked(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerColumnclicked(obj, handler, action = NULL, ...) addHandlerColumnDoubleclicked(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerColumnDoubleclicked(obj, handler, action = NULL, ...) addHandlerColumnRightclicked(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerColumnRightclicked(obj, handler, action = NULL, ...) addHandlerSelect(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerSelect(obj, handler, action = NULL, ...) addHandlerSelectionChanged(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerSelectionChanged(obj, handler, action = NULL, ...) addHandlerFocus(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerFocus(obj, handler, action = NULL, ...) addHandlerBlur(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerBlur(obj, handler, action = NULL, ...) addHandlerDestroy(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerDestroy(obj, handler, action = NULL, ...) addHandlerUnrealize(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerUnrealize(obj, handler, action = NULL, ...) addHandlerExpose(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerExpose(obj, handler, action = NULL, ...) addHandlerKeystroke(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerKeystroke(obj, handler, action = NULL, ...) addHandlerMouseMotion(obj, handler, action = NULL, ...) ## Default S3 method: addHandlerMouseMotion(obj, handler, action = NULL, ...) addHandlerIdle(...) addPopupMenu(obj, menulist, action = NULL, ...) ## Default S3 method: addPopupMenu(obj, menulist, action = NULL, ...) addRightclickPopupMenu(obj, menulist, action = NULL, ...) ## Default S3 method: addRightclickPopupMenu(obj, menulist, action = NULL, ...) ## Default S3 method: addRightclickPopupMenu(obj, menulist, action = NULL, ...) ## Default S3 method: addRightclickPopupMenu(obj, menulist, action = NULL, ...) addDropSource( obj, handler, action = NULL, data.type = c("text", "object"), ... ) ## Default S3 method: addDropSource( obj, handler, action = NULL, data.type = c("text", "object"), ... ) addDropTarget(obj, handler, action = NULL, ...) ## Default S3 method: addDropTarget(obj, handler, action = NULL, ...) addDragMotion(obj, handler, action = NULL, ...) ## Default S3 method: addDragMotion(obj, handler, action = NULL, ...) blockHandlers(obj, ...) ## Default S3 method: blockHandlers(obj, ...) blockHandler(obj, ID, ...) ## Default S3 method: blockHandler(obj, ID, ...) unblockHandlers(obj, ...) ## Default S3 method: unblockHandlers(obj, ...) unblockHandler(obj, ID, ...) ## Default S3 method: unblockHandler(obj, ID, ...) removeHandler(obj, ID, ...) ## Default S3 method: removeHandler(obj, ID, ...)
obj |
object receiving event and emitting a signal to the handler |
handler |
handler to assign when signal is emitted. A handler
is a function, its first argument should expect a list with
components |
action |
passed to handler to parameterize call. |
... |
passed along |
signal |
toolkit signal, e.g. "clicked" |
menulist |
a list of |
data.type |
Type of data returned. It is either text or an object |
ID |
returned by addHandler. If missing will try to block all handler passed to constructor |
Although the add_handler
method, to which addHandler
dispatches, is basically the workhorse to add a handler to
response to a signal, it generally isn't called directly, as its
use is not cross toolkit. Rather, if possible, one should use the
addHandlerXXX
methods to add a handler. These dispatch to
this (basically) but do so in a toolkit independent manner.
This call (and the others) returns a handler ID which may be used
for some toolkits later on to remove, block or unblock the
call. All handlers for a widget may be blocked or unblocked via
blockHandlers
and unblockHandlers
.
The "changed" event is also the one that a handler passed to the constructor is called on.
To specify the values that is transferred in a drag and drop
event, the handler specified here should return the value to pass
via drag and drop. It will appear as the dropdata
component
of the list passed in as the first argument of the drop handler
a handler ID which can be used to block/unblock or remove the handler
This method is not toolkit independent, as the signal value depends on the toolkit
For the gWidgets2Qt package one can not block, unblock or remove a single handler, but rather must do all the objects handlers at once.
blockHandlers
,
unblockHandlers
, blockHandler
,
unblockHandler
, and removeHandler
blockHandlers
to block all handlers for widget
A spring will separate the children packed in the box container prior to the spring be added and those being added, pushing the two as far apart as the allocated space will allow.
Add spring to GContainer class
Inserts a specific amount of space between the previously packed child and next one.
Add space to GContainer class
addSpring(obj) ## S3 method for class 'GContainer' addSpring(obj) addSpace(obj, value) ## S3 method for class 'GContainer' addSpace(obj, value)
addSpring(obj) ## S3 method for class 'GContainer' addSpring(obj) addSpace(obj, value) ## S3 method for class 'GContainer' addSpace(obj, value)
obj |
GContainer object |
value |
space in pixels to add |
Method to add icon to list of stock icons
generic for dispath
toolkit implementation
return list of available stock icons
generic for toolkit dispatch
default
Return stock icon name, filename, icon object from its by name
generic
default implementation
Find a stock icon from the given class
generic for dispath
Default stock icon for a given class name
Find stock icon from the given object
generic for dispath
get stock icon from object by class
addStockIcons(iconNames, iconFiles, ..., toolkit = guiToolkit()) .addStockIcons(toolkit, iconNames, iconFiles, ...) ## Default S3 method: .addStockIcons(toolkit, iconNames, iconFiles, ...) getStockIcons(..., toolkit = guiToolkit()) .getStockIcons(toolkit, ...) ## Default S3 method: .getStockIcons(toolkit, ...) getStockIconByName(name, ..., toolkit = guiToolkit()) .getStockIconByName(toolkit, name, ...) ## Default S3 method: .getStockIconByName(toolkit, name, file = TRUE, ...) stockIconFromClass(theClass, ..., toolkit = guiToolkit()) .stockIconFromClass(toolkit, theClass, ...) ## Default S3 method: .stockIconFromClass(toolkit, theClass, ...) stockIconFromObject(obj, ..., toolkit = guiToolkit()) .stockIconFromObject(toolkit, obj, ...) ## Default S3 method: .stockIconFromObject(toolkit, obj, ...)
addStockIcons(iconNames, iconFiles, ..., toolkit = guiToolkit()) .addStockIcons(toolkit, iconNames, iconFiles, ...) ## Default S3 method: .addStockIcons(toolkit, iconNames, iconFiles, ...) getStockIcons(..., toolkit = guiToolkit()) .getStockIcons(toolkit, ...) ## Default S3 method: .getStockIcons(toolkit, ...) getStockIconByName(name, ..., toolkit = guiToolkit()) .getStockIconByName(toolkit, name, ...) ## Default S3 method: .getStockIconByName(toolkit, name, file = TRUE, ...) stockIconFromClass(theClass, ..., toolkit = guiToolkit()) .stockIconFromClass(toolkit, theClass, ...) ## Default S3 method: .stockIconFromClass(toolkit, theClass, ...) stockIconFromObject(obj, ..., toolkit = guiToolkit()) .stockIconFromObject(toolkit, obj, ...) ## Default S3 method: .stockIconFromObject(toolkit, obj, ...)
iconNames |
names of icons |
iconFiles |
path of icons |
... |
ignored |
toolkit |
used to dispatch into toolkit if a separate implementation is made |
name |
of stock icon |
file |
logical If TRUE, return filename. If FALSE, return toolkit icon object (if possible). |
theClass |
name of class |
obj |
an R object |
list of icons with names the icon name and values the icon file name or icon object (as needed by the toolkit)
name of icon.
## Not run: ## we can add icon sets, say those of glyphicons.com. Steps are download files, unzip ## then point x to path, y to name. Imagine we download and current directory is ## png directory. (Won't work with tcltk by default as these are png files) x <- Sys.glob("*.png") path <- paste(getwd(), x, sep=.Platform$file.sep) nm <- gsub("\\.png", "", x) nm <- gsub("-", "_", nm) nm <- gsub("\\+", "_plus", nm) addStockIcons(nm, path) ## End(Not run)
## Not run: ## we can add icon sets, say those of glyphicons.com. Steps are download files, unzip ## then point x to path, y to name. Imagine we download and current directory is ## png directory. (Won't work with tcltk by default as these are png files) x <- Sys.glob("*.png") path <- paste(getwd(), x, sep=.Platform$file.sep) nm <- gsub("\\.png", "", x) nm <- gsub("-", "_", nm) nm <- gsub("\\+", "_plus", nm) addStockIcons(nm, path) ## End(Not run)
helper function to bypass lack of cached value in method call
call_meth(meth, obj)
call_meth(meth, obj)
meth |
method name |
obj |
method of object's class |
the method
use as do.call(call_meth, args)
Many arguments were deprecated due to various reasons. This is meant to ease porting of code.
check_deprecated(deprecated_args = list(), ...)
check_deprecated(deprecated_args = list(), ...)
deprecated_args |
named list of deprecated args |
... |
named avlues |
The S3 dispatch assumes naming conventions in the class names. This offers some check.
check_return_class(obj, ret_class)
check_return_class(obj, ret_class)
obj |
object with expected return class |
ret_class |
character string of class expected |
throws error if a mismatch
Dispose of object, primarily a window though this is modified in
GNoteBook
and GText
.
dispose(obj, ...) ## S3 method for class 'GComponent' dispose(obj, ...)
dispose(obj, ...) ## S3 method for class 'GComponent' dispose(obj, ...)
obj |
object to dispose |
... |
passed along |
Some widgets may be editable. If possible, the setter method can be used to toggle the state. This method indicates the state.
editable(obj, i) ## Default S3 method: editable(obj, i) editable(obj, i) <- value editable(obj, i) <- value
editable(obj, i) ## Default S3 method: editable(obj, i) editable(obj, i) <- value editable(obj, i) <- value
obj |
object |
i |
index to apply to, when applicable |
value |
logical. Set editable state. |
A widget is enabled if it is sensitive to user input
enabled(obj) ## Default S3 method: enabled(obj) enabled(obj) <- value enabled(obj) <- value
enabled(obj) ## Default S3 method: enabled(obj) enabled(obj) <- value enabled(obj) <- value
obj |
object |
value |
logical |
logical indicating if widget is enabled
if value
is logical and FALSE
widget will be insensitive to user input and rendered in a muted state.
Flatten a nested list
flatten(x)
flatten(x)
x |
a list |
Tommy (http://stackoverflow.com/questions/8139677/how-to-flatten-a-list-to-a-list-without-coercion)
a widget has focus if it will receive input events
For some widgets, this sets user focus (e.g. gedit gets focus for typing). For others, settig the focus calls the raise methods. (for gwindow, it will raise the window)
focus(obj) ## Default S3 method: focus(obj) focus(obj) <- value focus(obj) <- value
focus(obj) ## Default S3 method: focus(obj) focus(obj) <- value focus(obj) <- value
obj |
object |
value |
logical. Set focus state. |
The font
assignment method is used to change the font of
the currently selected text.
font(obj) ## Default S3 method: font(obj) font(obj) <- value font(obj) <- value ## S3 replacement method for class 'GText' font(obj) <- value
font(obj) ## Default S3 method: font(obj) font(obj) <- value font(obj) <- value ## S3 replacement method for class 'GText' font(obj) <- value
obj |
object |
value |
The font specification is given in terms of a named vector or list where the names indicate a font attribute and the value a reasonable choice:
These are from Gtk's font specs, which though fairly standard, may not be totally supported in the other toolkits. |
A action object encapsulates an action (a callback) adding textual and graphic information. Actions may be proxied in buttons, menu bars or tool bars.
gaction( label, tooltip = NULL, icon = NULL, key.accel = NULL, handler = NULL, action = NULL, parent = NULL, ..., toolkit = guiToolkit() ) .gaction( toolkit, label, tooltip = NULL, icon = NULL, key.accel = NULL, handler = NULL, action = NULL, parent = NULL, ... )
gaction( label, tooltip = NULL, icon = NULL, key.accel = NULL, handler = NULL, action = NULL, parent = NULL, ..., toolkit = guiToolkit() ) .gaction( toolkit, label, tooltip = NULL, icon = NULL, key.accel = NULL, handler = NULL, action = NULL, parent = NULL, ... )
label |
label for action |
tooltip |
toolktip for actin |
icon |
icon (stock icon name) for icon |
key.accel |
keyboard accelerator. If given, parent must be specified. |
handler |
handler to call when action is invoked |
action |
values passed to parameterize action |
parent |
parent window. Needed if keyboard accelerator used. |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
a gaction instance
Alert dialog to display transient messages
generic for toolkit dispatch
galert( msg, title = "message", delay = 3, parent = NULL, ..., toolkit = guiToolkit() ) .galert(toolkit, msg, title = "message", delay = 3, parent = NULL, ...)
galert( msg, title = "message", delay = 3, parent = NULL, ..., toolkit = guiToolkit() ) .galert(toolkit, msg, title = "message", delay = 3, parent = NULL, ...)
msg |
character. main message. If length is 2, second component is used for detail, providing it is available. |
title |
Title (may not be displayed) |
delay |
length of time (in seconds) to display |
parent |
parent object to show near |
... |
ignored |
toolkit |
toolkit |
gmessage
, gconfirm
,
gbasicdialog
, galert
The basic dialog is basically a modal window. To use there is a 3
step process: 1) Create a container by calling this constructor,
say dlg
; 2) use dlg
as a container for your
subsequent GUI; 3) set the dialog to be modal by calling
visible(dlg)
. (One can't call visible(dlg)
<- TRUE
.)
We overrided the basic use of visible
for the
gbasicdialog
container to have it become visible and modal
after this call. The better suited call visible(dlg) <-
TRUE
does not work as wanted, for we want to capture the return
value.
dispose method for a basic dialog
gbasicdialog( title = "Dialog", parent = NULL, do.buttons = TRUE, handler = NULL, action = NULL, ..., toolkit = guiToolkit() ) .gbasicdialog( toolkit, title = "Dialog", parent = NULL, do.buttons = TRUE, handler = NULL, action = NULL, ... ) ## S3 method for class 'GBasicDialog' visible(obj, ...) ## S3 method for class 'GBasicDialog' dispose(obj, ...)
gbasicdialog( title = "Dialog", parent = NULL, do.buttons = TRUE, handler = NULL, action = NULL, ..., toolkit = guiToolkit() ) .gbasicdialog( toolkit, title = "Dialog", parent = NULL, do.buttons = TRUE, handler = NULL, action = NULL, ... ) ## S3 method for class 'GBasicDialog' visible(obj, ...) ## S3 method for class 'GBasicDialog' dispose(obj, ...)
title |
title for window |
parent |
parent to display by |
do.buttons |
FALSE to suppress buttons when no parent |
handler |
handler called when |
action |
passed to handler for OK button |
... |
ignored |
toolkit |
toolkit |
obj |
dialog object |
A GBasicDialog
instance with a visible method
logical indicating which button was pushed (or TRUE if no buttons present)
gmessage
, gconfirm
,
gbasicdialog
, galert
## Not run: ## a modal dialog for editing a data frme fix_df <- function(DF, ...) { dfname <- deparse(substitute(DF)) w <- gbasicdialog(..., handler=function(h,...) { assign(dfname, df[,], .GlobalEnv) }) g <- ggroup(cont=w, horizontal=FALSE) glabel("Edit a data frame", cont=g) df <- gdf(DF, cont=g, expand=TRUE) size(w) <- c(400, 400) out <- visible(w) } m <- mtcars[1:3, 1:4] fix_df(m) ## End(Not run)
## Not run: ## a modal dialog for editing a data frme fix_df <- function(DF, ...) { dfname <- deparse(substitute(DF)) w <- gbasicdialog(..., handler=function(h,...) { assign(dfname, df[,], .GlobalEnv) }) g <- ggroup(cont=w, horizontal=FALSE) glabel("Edit a data frame", cont=g) df <- gdf(DF, cont=g, expand=TRUE) size(w) <- c(400, 400) out <- visible(w) } m <- mtcars[1:3, 1:4] fix_df(m) ## End(Not run)
The basic button widget is a standard means to provide the user a
mechanism to invoke an action. This action may be specified by a
handler or by a gaction
object. The main property for
GButton
is the label text. If this text matches a stock
icon name and the toolkit supports it, an icon will accompany the
button.
The svalue
method for a button object refers to its main property, the button label
gbutton( text = "", handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gbutton(toolkit, text, handler, action, container, ...) ## S3 method for class 'GButton' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GButton' svalue(obj, index = NULL, drop = NULL, ...)
gbutton( text = "", handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gbutton(toolkit, text, handler, action, container, ...) ## S3 method for class 'GButton' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GButton' svalue(obj, index = NULL, drop = NULL, ...)
text |
label text. If text matches a stock icon name, that is used as well |
handler |
A handler assigned to the default change
signal. Handlers are called when some event triggers a widget to
emit a signal. For each widget some default signal is assumed, and
handlers may be assigned to that through Handlers may also be added via |
action |
User supplied data passed to the handler when it is called |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
obj |
object receiving event and emitting a signal to the handler |
index |
NULL or logical. If |
drop |
NULL or logical. If widget supports it, drop will work as it does in a data frame or perhaps someother means. |
a GButton
instance. While this object has its own
(reference) methods, one primarily interacts with it through S3
methods defined within the package.
if(interactive()) { w <- gwindow("Buttons", visible=FALSE) g <- ggroup(cont=w, horizontal=FALSE) ## various buttons ## with icons b1 <- gbutton("open", cont=g) ## without icon b2 <- gbutton("ouvrir", cont=g) ## by an action act <- gaction("open", tooltip="open", icon="open", handler=function(...) {}) b3 <- gbutton(action=act, cont=g) ## with a handler b4 <- gbutton("click me", cont=g, handler=function(h,...) { if(svalue(b2) == "open") svalue(b2) <- "ouvrir" else svalue(b2) <- "open" }) ## handlers can be blocked/unblocked b5 <- gbutton("Click me for a message", cont=g) id <- addHandlerClicked(b5, function(h,...) print("Ouch")) b6 <- gcheckbox("toggle handler message", cont=g, use.togglebutton=TRUE, handler=function(h,...) { if (svalue(b6)) { blockHandler(b5, id) } else { unblockHandler(b5, id) } }) visible(w) <- TRUE }
if(interactive()) { w <- gwindow("Buttons", visible=FALSE) g <- ggroup(cont=w, horizontal=FALSE) ## various buttons ## with icons b1 <- gbutton("open", cont=g) ## without icon b2 <- gbutton("ouvrir", cont=g) ## by an action act <- gaction("open", tooltip="open", icon="open", handler=function(...) {}) b3 <- gbutton(action=act, cont=g) ## with a handler b4 <- gbutton("click me", cont=g, handler=function(h,...) { if(svalue(b2) == "open") svalue(b2) <- "ouvrir" else svalue(b2) <- "open" }) ## handlers can be blocked/unblocked b5 <- gbutton("Click me for a message", cont=g) id <- addHandlerClicked(b5, function(h,...) print("Ouch")) b6 <- gcheckbox("toggle handler message", cont=g, use.togglebutton=TRUE, handler=function(h,...) { if (svalue(b6)) { blockHandler(b5, id) } else { unblockHandler(b5, id) } }) visible(w) <- TRUE }
The date is the main property of this widget
The svalue
method for a calendar object returns the selected date
gcalendar( text = "", format = "%Y-%m-%d", handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gcalendar( toolkit, text = "", format = "%Y-%m-%d", handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GCalendar' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GCalendar' svalue(obj, index = NULL, drop = NULL, ...)
gcalendar( text = "", format = "%Y-%m-%d", handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gcalendar( toolkit, text = "", format = "%Y-%m-%d", handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GCalendar' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GCalendar' svalue(obj, index = NULL, drop = NULL, ...)
text |
initial text |
format |
Date format |
handler |
handler called when changed |
action |
passed to handler |
container |
parent container |
... |
passed to |
toolkit |
toolkit |
obj |
receiver object |
index |
ignored |
drop |
if |
Returns an object of class GCalendar
for which the following methods are overridden:
svalue
get the date
svalue<-
set the date
The change handler is inherited from gedit
If drop=TRUE
a character string, else a Date
class object.
A checkbox widget is used to toggle the state of a labeled boolean
variable. The main property of this widget is that state, not the
label. This variable may be proxied in the usual way – with a box
that indicates or check if TRUE
– or through a toggle
button.
The change handler for GCheckbox
is called when the value
toggles. You can inpsect the current value in the callback to have
an action based on the state.
The object state is referred to by svalue as a logical (TRUE for checked).
The svalue<-
method ensures the value is a logical vector
of length 1.
The item to select is referred to by the [
method, with only the first element being used.
gcheckbox( text = "", checked = FALSE, use.togglebutton = FALSE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gcheckbox( toolkit, text, checked = FALSE, use.togglebutton = FALSE, handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GCheckbox' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 replacement method for class 'GCheckbox' svalue(obj, index=NULL, ...) <- value ## S3 replacement method for class 'GCheckbox' x[i, j, ...] <- value
gcheckbox( text = "", checked = FALSE, use.togglebutton = FALSE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gcheckbox( toolkit, text, checked = FALSE, use.togglebutton = FALSE, handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GCheckbox' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 replacement method for class 'GCheckbox' svalue(obj, index=NULL, ...) <- value ## S3 replacement method for class 'GCheckbox' x[i, j, ...] <- value
text |
label text |
checked |
is button selected |
use.togglebutton |
Use a toggle button (shows depressed) not a check box |
handler |
Callback called when toggle is changed. |
action |
passed to handler |
container |
parent container |
... |
passed to |
toolkit |
toolkit |
obj |
receiver object |
index |
ignored. Input is coerced to logical. |
value |
assignment value |
x |
checkbox object |
i |
item index |
j |
ignored |
Returns an object of class GCheckbox
.
The value is coerced to character, then only first element used for checkbox label
if(interactive()) { w <- gwindow("Selection widgets") g <- gvbox(cont=w) fl <- gformlayout(cont=g) gcheckbox("checkbox", checked=TRUE, cont=fl, label="checkbox") gradio(state.name[1:4], selected=2, horizontal=TRUE, cont=fl, label="gradio") gcheckboxgroup(state.name[1:4], horizontal=FALSE, cont=fl, label="checkbox group") bg <- ggroup(cont=g) gbutton("ok", cont=bg, handler=function(h,...) print(sapply(fl$children, svalue))) }
if(interactive()) { w <- gwindow("Selection widgets") g <- gvbox(cont=w) fl <- gformlayout(cont=g) gcheckbox("checkbox", checked=TRUE, cont=fl, label="checkbox") gradio(state.name[1:4], selected=2, horizontal=TRUE, cont=fl, label="gradio") gcheckboxgroup(state.name[1:4], horizontal=FALSE, cont=fl, label="checkbox group") bg <- ggroup(cont=g) gbutton("ok", cont=bg, handler=function(h,...) print(sapply(fl$children, svalue))) }
Change handler for a GCheckboxGroup
p is called when any of the
checkboxes changes state.
The svalue
methods refer to the selected values. By default
these are the item values, coerced to characterq. When
index=TRUE
is specified, then the index is returned as an
integer vector. For setting, one may also use a vector of logicals
(which is recycled) for the index.
gcheckboxgroup( items, checked = FALSE, horizontal = FALSE, use.table = FALSE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gcheckboxgroup( toolkit, items, checked = FALSE, horizontal = FALSE, use.table = FALSE, handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GCheckboxGroup' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GCheckboxGroup' svalue(obj, index = NULL, drop = NULL, ...)
gcheckboxgroup( items, checked = FALSE, horizontal = FALSE, use.table = FALSE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gcheckboxgroup( toolkit, items, checked = FALSE, horizontal = FALSE, use.table = FALSE, handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GCheckboxGroup' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GCheckboxGroup' svalue(obj, index = NULL, drop = NULL, ...)
items |
checkbox labels |
checked |
logical. Are values checked |
horizontal |
logical. If true displayed horizontally, else vertically |
use.table |
logical. If supported, and |
handler |
A handler assigned to the default change
signal. Handlers are called when some event triggers a widget to
emit a signal. For each widget some default signal is assumed, and
handlers may be assigned to that through Handlers may also be added via |
action |
User supplied data passed to the handler when it is called |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
obj |
receiver object |
index |
NULL or logical. If |
drop |
NULL or logical. If widget supports it, drop will work as it does in a data frame or perhaps someother means. |
Returns an object of class GCheckboxGroup
for which
the following methods are overridden:
svalue
Return the selected values or an empty
character vector. If index=TRUE
, returns indices of
selected values.
svalue<-
Set the selected values one of three ways:
by label name, by a logical variable indicating which are selected
(if ambigous, logical wins), if index=TRUE
by the indices
to select.
[
returns labels
[<-
set the label values. Should be able to shorten
or lengthen list
if(interactive()) { w <- gwindow("Selection widgets") g <- gvbox(cont=w) fl <- gformlayout(cont=g) gcheckbox("checkbox", checked=TRUE, cont=fl, label="checkbox") gradio(state.name[1:4], selected=2, horizontal=TRUE, cont=fl, label="gradio") gcheckboxgroup(state.name[1:4], horizontal=FALSE, cont=fl, label="checkbox group") bg <- ggroup(cont=g) gbutton("ok", cont=bg, handler=function(h,...) print(sapply(fl$children, svalue))) }
if(interactive()) { w <- gwindow("Selection widgets") g <- gvbox(cont=w) fl <- gformlayout(cont=g) gcheckbox("checkbox", checked=TRUE, cont=fl, label="checkbox") gradio(state.name[1:4], selected=2, horizontal=TRUE, cont=fl, label="gradio") gcheckboxgroup(state.name[1:4], horizontal=FALSE, cont=fl, label="checkbox group") bg <- ggroup(cont=g) gbutton("ok", cont=bg, handler=function(h,...) print(sapply(fl$children, svalue))) }
A combobox can be either a drop down list (editable=FALSE), or a drop-down list and edit area (a combobox).
Non exported helper function to coerce items into a data frame. First column contains the values, second stock icons, third tooltips
Ensure that value is a data frame. One can pass a vector or a one-column data frame to inidicate the possible values for selection, a second column is used for an icons (if possible), a third for a tooltip (if possible).
Change handler for a non-editabe combobox is called when a new value is selected. For editable comboboxes, the handler is also called when the text entry box is activated.
The svalue
method for a combobox object refers to its main
property, the selected value. When index=FALSE
(or
NULL
) the value is returned. If index=TRUE
the index
of the object within the set of items is used.
gcombobox( items, selected = 1, editable = FALSE, coerce.with = NULL, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gcombobox( toolkit, items, selected = 1, editable = FALSE, coerce.with = NULL, handler = NULL, action = NULL, container = NULL, ... ) gdroplist(...) .make_gcombobox_items(value) ## S3 replacement method for class 'GComboBox' x[i , j, ...] <- value ## S3 method for class 'GComboBox' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GComboBox' svalue(obj, index = NULL, drop = NULL, ...)
gcombobox( items, selected = 1, editable = FALSE, coerce.with = NULL, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gcombobox( toolkit, items, selected = 1, editable = FALSE, coerce.with = NULL, handler = NULL, action = NULL, container = NULL, ... ) gdroplist(...) .make_gcombobox_items(value) ## S3 replacement method for class 'GComboBox' x[i , j, ...] <- value ## S3 method for class 'GComboBox' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GComboBox' svalue(obj, index = NULL, drop = NULL, ...)
items |
Items to select from. A vector or a data frame. If a data frame, then first column is values. Second is optional, but can specify a stock icon name, third is optional and can be used to specify a tooltip. These may not be supported in all toolkits. |
selected |
integer. Which item (by index) is selected. Use -1 for no selection |
editable |
logical. Is user allowed to edit value |
coerce.with |
A function of function name to be called before
selected value is returned by |
handler |
Called when combobox value is changed. |
action |
passed to handler |
container |
parent container |
... |
passed to parent container's |
toolkit |
toolkit |
value |
new items for selection |
x |
combobox object |
i |
item index |
j |
ignored |
obj |
object receiving event and emitting a signal to the handler |
index |
NULL or logical. If |
drop |
NULL or logical. If widget supports it, drop will work as it does in a data frame or perhaps someother means. |
Returns an object of class GComboBox
for which the following methods are overriden:
svalue
Return selected value by name or (if index=TRUE
by index). The latter only if editable=FALSE
.
svalue<-
Set the selected value by value or if index=TRUE
by index.
[
return items to select from
[<-
Set items to select from.
Constructor for modal dialog to get confirmation
generic for toolkit dispatch
gconfirm( msg, title = "Confirm", icon = c("info", "warning", "error", "question"), parent = NULL, ..., toolkit = guiToolkit() ) .gconfirm( toolkit, msg, title = "Confirm", icon = c("info", "warning", "error", "question"), parent = NULL, ... )
gconfirm( msg, title = "Confirm", icon = c("info", "warning", "error", "question"), parent = NULL, ..., toolkit = guiToolkit() ) .gconfirm( toolkit, msg, title = "Confirm", icon = c("info", "warning", "error", "question"), parent = NULL, ... )
msg |
Character. Message to display. |
title |
Character. Title of window |
icon |
which icon to display |
parent |
gives hint as to where to place dialog |
... |
ignored |
toolkit |
toolkit |
logical inidicating confirmation
gmessage
, gconfirm
,
gbasicdialog
, galert
Used as template for documentation
gcontainer(container = NULL, ..., toolkit = guiToolkit())
gcontainer(container = NULL, ..., toolkit = guiToolkit())
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
Implementation varies wildly, but should provide at minimum
functionality of edit.data.frame
. A single mouse click on a
cell should select that cell, a double click should initiate
editing of that cell.
Assign handler to be called when a cell, row or column changes
For gdf svalue refers to the selected values.
visible
is used to refer to which rows are being shown.
gdf( items = NULL, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gdf( toolkit, items = NULL, handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GDf' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GDf' svalue(obj, index = NULL, drop = TRUE, ...) ## S3 replacement method for class 'GDf' visible(obj) <- value
gdf( items = NULL, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gdf( toolkit, items = NULL, handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GDf' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GDf' svalue(obj, index = NULL, drop = TRUE, ...) ## S3 replacement method for class 'GDf' visible(obj) <- value
items |
data frame to edit |
handler |
called on cell change |
action |
passed to handler |
container |
parent container |
... |
passed to container's |
toolkit |
toolkit |
obj |
object receiving event and emitting a signal to the handler |
index |
NULL or logical. If |
drop |
NULL or logical. If widget supports it, drop will work as it does in a data frame or perhaps someother means. |
value |
value to assign for selection or property |
Contents of the data frame can be accessed via [
and manipulated with [<-
.
The save_data
reference class method can be called to
save the data into a variable with the specified name.
example in inst/examples/ex-gdf.R
An object of class gDf
.
gdf
instancesA notebook container for many gdf
instances
S3 generic whose methods are implemented in the toolkit packages
gdfnotebook(items = NULL, container = NULL, ..., toolkit = guiToolkit()) .gdfnotebook(toolkit, items, container, ...)
gdfnotebook(items = NULL, container = NULL, ..., toolkit = guiToolkit()) .gdfnotebook(toolkit, items, container, ...)
items |
data frame for initial page, when given |
container |
parent container |
... |
passed to |
toolkit |
toolkit |
The default change handler is called when the return key is
pressed. It can be useful to also call a handler when the widget
loses focus. For that, the addHandlerBlur
method is of
use. (This was the default, but is now not, as it was hard to
decouple the two when that was desirable.)
The default change handler call is when the user activates the
entry by pressing the enter key. Other possible events to consider are
covered by: addhandlerBlur
(when the widget loses focuses)
and addHandlerKeystroke
(called after each keystroke). For
the latter, if the toolkit supports it, the handler's first
argument has a component key
passing back the keystroke
information.
The svalue
method for a edit object refers to its main property, the text in the box.
gedit( text = "", width = 25, coerce.with = NULL, initial.msg = "", handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gedit( toolkit, text = "", width = 25, coerce.with = NULL, initial.msg = "", handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GEdit' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GEdit' svalue(obj, index = NULL, drop = NULL, ...)
gedit( text = "", width = 25, coerce.with = NULL, initial.msg = "", handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gedit( toolkit, text = "", width = 25, coerce.with = NULL, initial.msg = "", handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GEdit' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GEdit' svalue(obj, index = NULL, drop = NULL, ...)
text |
initial text |
width |
number of characters |
coerce.with |
A function or name of function to coerce value with before returning by |
initial.msg |
If no initial text is given but an initial message is, then this message is displayed until the widget receives the focus |
handler |
Change handler. Called when return key is hit. Use
|
action |
passed to handler |
container |
parent container |
... |
passed to |
toolkit |
toolkit |
obj |
object receiving event and emitting a signal to the handler |
index |
NULL or logical. If |
drop |
NULL or logical. If widget supports it, drop will work as it does in a data frame or perhaps someother means. |
An object of class GEdit
. This has sub-classed methods:
svalue
to retrieve the text
svalue<-
to set the text
[
to get the autocomplete values
[<-
Character. To set autocomplete values
visible<-
to specify a character to display instead of text (for passwords)
Like match, but works with a list
get_index_in_list(lst, ele)
get_index_in_list(lst, ele)
lst |
a list to search through |
ele |
element of list |
returns index of element or integer(0)
Get an object from an environment specified by a string.
get_object_from_string(value, envir = .GlobalEnv)
get_object_from_string(value, envir = .GlobalEnv)
value |
A single character value dispatches to get. For a length 2 or more, then assumes object is recursive and extracts named components |
envir |
environment to look for values. |
the object or an error
At times a user may wish to access the underlying toolkit widget. Although this is not cross-platform, one often has access to many more methods of the object, than through those provided by gWidgets.
For GWindow, the block is NULL
getToolkitWidget(obj) ## Default S3 method: getToolkitWidget(obj) getWidget(obj) ## S3 method for class 'GComponent' getWidget(obj) getBlock(obj) ## S3 method for class 'GComponent' getBlock(obj) ## S3 method for class 'GWindow' getBlock(obj) getTopLevel(obj) ## S3 method for class 'GComponent' getTopLevel(obj)
getToolkitWidget(obj) ## Default S3 method: getToolkitWidget(obj) getWidget(obj) ## S3 method for class 'GComponent' getWidget(obj) getBlock(obj) ## S3 method for class 'GComponent' getBlock(obj) ## S3 method for class 'GWindow' getBlock(obj) getTopLevel(obj) ## S3 method for class 'GComponent' getTopLevel(obj)
obj |
object |
Return x unless NULL, NA, length 0, ..., in which case we give default
getWithDefault(x, default)
getWithDefault(x, default)
x |
value to return or its default |
default |
default value |
x or default
For gexpandgroup, the visible assignment method is overridden to change the disclosure state
The change handler for a expandGroup is called when the group changes visibility
gexpandgroup( text = "", markup = FALSE, horizontal = TRUE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gexpandgroup( toolkit, text = "", markup = FALSE, horizontal = TRUE, handler = NULL, action = NULL, container = NULL, ... ) ## S3 replacement method for class 'GExpandGroup' visible(obj) <- value ## S3 method for class 'GExpandGroup' addHandlerChanged(obj, handler, action = NULL, ...)
gexpandgroup( text = "", markup = FALSE, horizontal = TRUE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gexpandgroup( toolkit, text = "", markup = FALSE, horizontal = TRUE, handler = NULL, action = NULL, container = NULL, ... ) ## S3 replacement method for class 'GExpandGroup' visible(obj) <- value ## S3 method for class 'GExpandGroup' addHandlerChanged(obj, handler, action = NULL, ...)
text |
Label text |
markup |
logical. Does text have markup? (Toolkit dependent: only implemented for |
horizontal |
horizontal ( |
handler |
handler called when state is toggled |
action |
passed to handler |
container |
parent container |
... |
passed to parent's |
toolkit |
toolkit |
obj |
object receiving event and emitting a signal to the handler |
value |
logical. If |
An object of class GExpandGroup
inheriting from GFrame
if(interactive()) { w <- gwindow("Box containers") g <- gvbox(cont=w) # ggroup(horizonta=FALSE, ...) nb <- gnotebook(cont=g); gbutton("one", label="one", cont=nb) gframe("Frame", cont=g) pg <- gpanedgroup(cont=g); gbutton("one", cont=pg); gbutton("two", cont=pg) eg <- gexpandgroup(cont=g, horizontal=FALSE); glabel("Click above to hide", cont=eg); gbutton("one", cont=eg); gbutton("two", cont=eg) }
if(interactive()) { w <- gwindow("Box containers") g <- gvbox(cont=w) # ggroup(horizonta=FALSE, ...) nb <- gnotebook(cont=g); gbutton("one", label="one", cont=nb) gframe("Frame", cont=g) pg <- gpanedgroup(cont=g); gbutton("one", cont=pg); gbutton("two", cont=pg) eg <- gexpandgroup(cont=g, horizontal=FALSE); glabel("Click above to hide", cont=eg); gbutton("one", cont=eg); gbutton("two", cont=eg) }
Basically an entry box instance with a button to initiate gfile
.
gfile( text = "", type = c("open", "save", "selectdir"), initial.filename = NULL, initial.dir = getwd(), filter = list(), multi = FALSE, ..., toolkit = guiToolkit() ) .gfile( toolkit, text = "", type = c("open", "save", "selectdir"), initial.filename = NULL, initial.dir = getwd(), filter = list(), multi = FALSE, ... ) gfilebrowse( text = "Select a file...", type = c("open", "save", "selectdir"), initial.filename = NULL, initial.dir = getwd(), filter = list(), quote = TRUE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gfilebrowse( toolkit, text = "Select a file...", type = c("open", "save", "selectdir"), initial.filename = NULL, initial.dir = getwd(), filter = list(), quote = TRUE, handler = NULL, action = NULL, container = NULL, ... )
gfile( text = "", type = c("open", "save", "selectdir"), initial.filename = NULL, initial.dir = getwd(), filter = list(), multi = FALSE, ..., toolkit = guiToolkit() ) .gfile( toolkit, text = "", type = c("open", "save", "selectdir"), initial.filename = NULL, initial.dir = getwd(), filter = list(), multi = FALSE, ... ) gfilebrowse( text = "Select a file...", type = c("open", "save", "selectdir"), initial.filename = NULL, initial.dir = getwd(), filter = list(), quote = TRUE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gfilebrowse( toolkit, text = "Select a file...", type = c("open", "save", "selectdir"), initial.filename = NULL, initial.dir = getwd(), filter = list(), quote = TRUE, handler = NULL, action = NULL, container = NULL, ... )
text |
initial text |
type |
type of browser: to open a file, to save a file or to select a directory |
initial.filename |
Suggested file name |
initial.dir |
initial directory. If a filename is given, and is not an absolute name, this will be prepended. If filename given initial directory will be taken from that. |
filter |
A filter specifiation. This can be a named character vector of file extensions or something toolkit specific. Here are some examples:
|
multi |
Logical. Allow multiple files to be selected? |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
quote |
quote output |
handler |
A handler assigned to the default change
signal. Handlers are called when some event triggers a widget to
emit a signal. For each widget some default signal is assumed, and
handlers may be assigned to that through Handlers may also be added via |
action |
User supplied data passed to the handler when it is called |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
returns filename(s) or character(0)
if no selection.
Returns an object of class gFilebrowse
. This should
inherit the methods of gedit
instances.
This widget provides a simple means to subset, or filter, a data frame.
The svalue
method for a filter object returns a logical
containing which rows are selected. There is no assignment method.
gfilter( DF, allow.edit = TRUE, initial.vars = NULL, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gfilter( toolkit, DF, allow.edit = TRUE, initial.vars = NULL, handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GFilter' svalue(obj, index = NULL, drop = NULL, ...) ## S3 method for class 'GFilter' x[i, j, ..., drop = TRUE] ## Default S3 method: .gfilter( toolkit = guiToolkit(), DF, allow.edit = TRUE, initial.vars = NULL, handler = NULL, action = NULL, container = NULL, ... )
gfilter( DF, allow.edit = TRUE, initial.vars = NULL, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gfilter( toolkit, DF, allow.edit = TRUE, initial.vars = NULL, handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GFilter' svalue(obj, index = NULL, drop = NULL, ...) ## S3 method for class 'GFilter' x[i, j, ..., drop = TRUE] ## Default S3 method: .gfilter( toolkit = guiToolkit(), DF, allow.edit = TRUE, initial.vars = NULL, handler = NULL, action = NULL, container = NULL, ... )
DF |
a data frame or |
allow.edit |
logical. If |
initial.vars |
When given, this is a data frame whose first
column specifies the variables within |
handler |
A handler assigned to the default change
signal. Handlers are called when some event triggers a widget to
emit a signal. For each widget some default signal is assumed, and
handlers may be assigned to that through Handlers may also be added via |
action |
User supplied data passed to the handler when it is called |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
dots argument |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
obj |
object of method call |
index |
NULL or logical. If |
drop |
NULL or logical. If widget supports it, drop will work as it does in a data frame or perhaps someother means. |
x |
the |
i |
passed to |
j |
passed to |
returns GFilter
object
## Not run: DF <- mtcars[, c("mpg", "cyl", "hp", "am", "wt")] w <- gwindow("Example of gfilter", visible=FALSE) pg <- ggroup(container=w) df <- gtable(DF, container=pg) a <- gfilter(df, initial.vars=data.frame(names(DF), names(DF), c("single", "multiple", "range", "single", "range"), stringsAsFactors=FALSE), allow.edit=TRUE, container=pg, handler=function(h,...) { visible(df) <- h$obj$get_value() } ) size(w) <- c(600, 600) visible(w) <- TRUE ## End(Not run)
## Not run: DF <- mtcars[, c("mpg", "cyl", "hp", "am", "wt")] w <- gwindow("Example of gfilter", visible=FALSE) pg <- ggroup(container=w) df <- gtable(DF, container=pg) a <- gfilter(df, initial.vars=data.frame(names(DF), names(DF), c("single", "multiple", "range", "single", "range"), stringsAsFactors=FALSE), allow.edit=TRUE, container=pg, handler=function(h,...) { visible(df) <- h$obj$get_value() } ) size(w) <- c(600, 600) visible(w) <- TRUE ## End(Not run)
This convenience container is basically a simpler form of
glayout
to be used to layout two columns forms with a label
on the left. The label can be passed in to the add
method
of the container as is done with notebook labels
The svalue
method for GFormLayout
returns a list of
values created by calling svalue
on each child. The
returned list is named by the corresponding labels.
gformlayout( align = c("default", "left", "center"), spacing = 5, container = NULL, ..., toolkit = guiToolkit() ) .gformlayout(toolkit, align = "left", spacing = 5, container = NULL, ...) ## S3 method for class 'GFormLayout' svalue(obj, index = NULL, drop = NULL, ...)
gformlayout( align = c("default", "left", "center"), spacing = 5, container = NULL, ..., toolkit = guiToolkit() ) .gformlayout(toolkit, align = "left", spacing = 5, container = NULL, ...) ## S3 method for class 'GFormLayout' svalue(obj, index = NULL, drop = NULL, ...)
align |
alignment of label. Left justify or center balance. Leave as "default" for underlying toolkit default. |
spacing |
spacing between columns |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
obj |
object of method call |
index |
NULL or logical. If |
drop |
NULL or logical. If widget supports it, drop will work as it does in a data frame or perhaps someother means. |
## Not run: w <- gwindow("gformlayout", visible=FALSE) g <- gvbox(container=w) flyt <- gformlayout(container=g) gedit("", label="Name:", container=flyt) gedit("", label="Rank:", container=flyt) gedit("", label="Serial No.:", container=flyt) b <- gbutton("Show me", container=g, handler=function(h,...) { print(svalue(flyt)) }) addSpring(g) ## better with Qt, else flyt expands to fill. visible(w) <- TRUE ## End(Not run)
## Not run: w <- gwindow("gformlayout", visible=FALSE) g <- gvbox(container=w) flyt <- gformlayout(container=g) gedit("", label="Name:", container=flyt) gedit("", label="Rank:", container=flyt) gedit("", label="Serial No.:", container=flyt) b <- gbutton("Show me", container=g, handler=function(h,...) { print(svalue(flyt)) }) addSpring(g) ## better with Qt, else flyt expands to fill. visible(w) <- TRUE ## End(Not run)
The framed box container inherits from ggroup
. The main
addition is a label, which is accessed via the name
method.
gframe( text = "", markup = FALSE, pos = 0, horizontal = TRUE, spacing = 5, container = NULL, ..., toolkit = guiToolkit() ) .gframe( toolkit, text = "", markup = FALSE, pos = 0, horizontal = TRUE, spacing = 5, container = NULL, ... )
gframe( text = "", markup = FALSE, pos = 0, horizontal = TRUE, spacing = 5, container = NULL, ..., toolkit = guiToolkit() ) .gframe( toolkit, text = "", markup = FALSE, pos = 0, horizontal = TRUE, spacing = 5, container = NULL, ... )
text |
frame label |
markup |
does label use markup (toolkit specific) |
pos |
position of label: 0=left, 1=right, some toolkit allow values in between |
horizontal |
logical. If TRUE, left to right layout, otherwise top to bottom |
spacing |
spacing aroud widget |
container |
parent container |
... |
passed through |
toolkit |
toolkit |
to include a scrollwindow, place a ggroup
within this window.
ggroup
and gexpandgroup
## Not run: w <- gwindow("gformlayout", visible=FALSE) f <- gframe("frame", horizontal=FALSE, container=w) glabel("Lorem ipsum dolor sit amet, \nconsectetur adipiscing elit.", container=f) gbutton("change name", container=f, handler=function(h,...) { names(f) <- "new name" }) visible(w) <- TRUE ## End(Not run)
## Not run: w <- gwindow("gformlayout", visible=FALSE) f <- gframe("frame", horizontal=FALSE, container=w) glabel("Lorem ipsum dolor sit amet, \nconsectetur adipiscing elit.", container=f) gbutton("change name", container=f, handler=function(h,...) { names(f) <- "new name" }) visible(w) <- TRUE ## End(Not run)
Some toolkits provide an embeddable graphics device. When this is the case, this widget provides same.
ggraphics( width = dpi * 6, height = dpi * 6, dpi = 75, ps = 12, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .ggraphics( toolkit, width = dpi * 6, height = dpi * 6, dpi = 75, ps = 12, handler = NULL, action = NULL, container = NULL, ... )
ggraphics( width = dpi * 6, height = dpi * 6, dpi = 75, ps = 12, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .ggraphics( toolkit, width = dpi * 6, height = dpi * 6, dpi = 75, ps = 12, handler = NULL, action = NULL, container = NULL, ... )
width |
width of device (pixels) |
height |
hieght of widget (pixels) |
dpi |
dots per inch |
ps |
pointsize |
handler |
A handler assigned to the default change
signal. Handlers are called when some event triggers a widget to
emit a signal. For each widget some default signal is assumed, and
handlers may be assigned to that through Handlers may also be added via |
action |
User supplied data passed to the handler when it is called |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
## Not run: ## This shows how to use the device within a notebook w <- gwindow("notebook example") nb <- gnotebook(cont=w) devs <- lapply(1:5, function(i) ggraphics(cont=nb, label=as.character(i))) addHandlerChanged(nb, handler=function(h,...) { ## Tricky part is svalue(h$obj) is not the new page number -- but old ## so we use the pageno component here gg <- h$obj[h$pageno] visible(gg) <- TRUE }) ## End(Not run)
## Not run: ## This shows how to use the device within a notebook w <- gwindow("notebook example") nb <- gnotebook(cont=w) devs <- lapply(1:5, function(i) ggraphics(cont=nb, label=as.character(i))) addHandlerChanged(nb, handler=function(h,...) { ## Tricky part is svalue(h$obj) is not the new page number -- but old ## so we use the pageno component here gg <- h$obj[h$pageno] visible(gg) <- TRUE }) ## End(Not run)
A notebook widget holding plot devices
S3 generic whose methods are implemented in the toolkit packages
toolkit implementation
ggraphicsnotebook( width = dpi * 6, height = dpi * 6, dpi = 75, container = NULL, ..., toolkit = guiToolkit() ) .ggraphicsnotebook(toolkit, width, height, dpi, container, ...) ## Default S3 method: .ggraphicsnotebook(toolkit, width, height, dpi, container, ...)
ggraphicsnotebook( width = dpi * 6, height = dpi * 6, dpi = 75, container = NULL, ..., toolkit = guiToolkit() ) .ggraphicsnotebook(toolkit, width, height, dpi, container, ...) ## Default S3 method: .ggraphicsnotebook(toolkit, width, height, dpi, container, ...)
width |
width in pixels |
height |
height in pixels |
dpi |
screen resolution |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
The svalue
method refers to the main property of the box
container, its spacing. There are generally two types of spacing:
padding around border of the box and spacing between each child
that is packed in. The spacing here is the between-child-component spacing.
The reference class method set_borderwidth
can be used for the other.
Avoids need to type horizontal=FALSE
ggroup( horizontal = TRUE, spacing = 5, use.scrollwindow = FALSE, container = NULL, ..., toolkit = guiToolkit() ) .ggroup( toolkit, horizontal = TRUE, spacing = 5, use.scrollwindow = FALSE, container = NULL, ... ) ## S3 replacement method for class 'GGroup' svalue(obj, index=TRUE, ...) <- value gvbox( spacing = 5, use.scrollwindow = FALSE, container = NULL, ..., toolkit = guiToolkit() )
ggroup( horizontal = TRUE, spacing = 5, use.scrollwindow = FALSE, container = NULL, ..., toolkit = guiToolkit() ) .ggroup( toolkit, horizontal = TRUE, spacing = 5, use.scrollwindow = FALSE, container = NULL, ... ) ## S3 replacement method for class 'GGroup' svalue(obj, index=TRUE, ...) <- value gvbox( spacing = 5, use.scrollwindow = FALSE, container = NULL, ..., toolkit = guiToolkit() )
horizontal |
logical. If TRUE, left to right layout, otherwise top to bottom |
spacing |
spacing aroud widget |
use.scrollwindow |
logical. Either |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
obj |
|
index |
ignored |
value |
value (in pixels) for between child spacing |
Child components are typically added to a box container through
the child components constructor. The argument expand
,
fill
, and anchor
determine how the child is
positioned within the container.
a GGroup instance.
a GGroup instance with vertical packing.
gframe
and gexpandgroup
if(interactive()) { w <- gwindow("Box containers") g <- gvbox(cont=w) # ggroup(horizonta=FALSE, ...) nb <- gnotebook(cont=g); gbutton("one", label="one", cont=nb) gframe("Frame", cont=g) pg <- gpanedgroup(cont=g); gbutton("one", cont=pg); gbutton("two", cont=pg) }
if(interactive()) { w <- gwindow("Box containers") g <- gvbox(cont=w) # ggroup(horizonta=FALSE, ...) nb <- gnotebook(cont=g); gbutton("one", label="one", cont=nb) gframe("Frame", cont=g) pg <- gpanedgroup(cont=g); gbutton("one", cont=pg); gbutton("two", cont=pg) }
This widget, when supported by the toolkit (not gWidgets2RGtk2 and gWidgets2tcltk) provides a simple means to display HTML formatted text.
Use to update displayed content. Value is HTML fragment or url
ghtml(x, container = NULL, ..., toolkit = guiToolkit()) .ghtml(toolkit, x, container = NULL, ...) ## S3 replacement method for class 'GHtml' svalue(obj, index=TRUE, ...) <- value
ghtml(x, container = NULL, ..., toolkit = guiToolkit()) .ghtml(toolkit, x, container = NULL, ...) ## S3 replacement method for class 'GHtml' svalue(obj, index=TRUE, ...) <- value
x |
url or character vector of HTML formatted text. URLs marked by "http://" prefix |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
obj |
object of method call |
index |
NULL or logical. If |
value |
value to assign for selection or property |
a GHtml
instance.
john verzani
A widget for displaying an image file
generic for toolkit dispatch
gimage( filename = "", dirname = "", stock.id = NULL, size = "", handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gimage( toolkit, filename = "", dirname = "", stock.id = NULL, size = "", handler = NULL, action = NULL, container = NULL, ... )
gimage( filename = "", dirname = "", stock.id = NULL, size = "", handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gimage( toolkit, filename = "", dirname = "", stock.id = NULL, size = "", handler = NULL, action = NULL, container = NULL, ... )
filename |
basename of file |
dirname |
dirname of file |
stock.id |
stock id of icon (if non NULL) |
size |
size of icon when a stock id (toolkit dependent) |
handler |
handler if image is clicked on. |
action |
passed to handler |
container |
parent container |
... |
passed to add method of parent |
toolkit |
toolkit |
Constructor for modal dialog to collect a line of text
generic for toolkit dispatch
ginput( msg, text = "", title = "Input", icon = c("info", "warning", "error", "question"), parent = NULL, ..., toolkit = guiToolkit() ) .ginput( toolkit, msg, text = "", title = "Input", icon = c("info", "warning", "error", "question"), parent = NULL, ... )
ginput( msg, text = "", title = "Input", icon = c("info", "warning", "error", "question"), parent = NULL, ..., toolkit = guiToolkit() ) .ginput( toolkit, msg, text = "", title = "Input", icon = c("info", "warning", "error", "question"), parent = NULL, ... )
msg |
Character. Message to display. |
text |
Character. Initial text |
title |
Character. Title of window |
icon |
which icon to display |
parent |
gives hint as to where to place dialog |
... |
ignored |
toolkit |
toolkit |
value typed into box or character(0)
gmessage
, gconfirm
,
gbasicdialog
, galert
The basic label widget allows one to label areas of a GUI using text. The most common use would be to label fields in a form. For gWidgets2 labels may be editable or responsive to mouse clicks, although it is the author's experience that such uses are not expected by the end user.
The svalue
methods refer to the main property of the label, its text.
glabel( text = "", markup = FALSE, editable = FALSE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .glabel( toolkit, text, markup = FALSE, editable = FALSE, handler = NULL, action = NULL, container = NULL, ... ) ## S3 replacement method for class 'GLabel' svalue(obj, index=TRUE, ...) <- value
glabel( text = "", markup = FALSE, editable = FALSE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .glabel( toolkit, text, markup = FALSE, editable = FALSE, handler = NULL, action = NULL, container = NULL, ... ) ## S3 replacement method for class 'GLabel' svalue(obj, index=TRUE, ...) <- value
text |
character. Collapsed using a newline to a single string. |
markup |
logical. If toolkit supports markup, this indicates
it will be used. It is suggested that the |
editable |
If TRUE, then clicking on label will enable user-editing of the text. |
handler |
optional handler. If given, added through addHandlerChanged. Overridden if |
action |
passed to handler through |
container |
parent container (Optional for some toolkits, but not all). |
... |
passed to |
toolkit |
toolkit instance |
obj |
object of method call |
index |
NULL or logical. If |
value |
value to assign for selection or property |
a GLabel
instance. While this object has its own (reference) methods, one primarily interacts with it through S3 methods defined within the package.
john verzani
## Not run: w <- gwindow("gformlayout", visible=FALSE) g <- gvbox(container=w) g$set_borderwidth(10) l1 <- glabel("static label", container=g) l2 <- glabel("bold label", container=g) font(l2) <- list(weight="bold") l3 <- glabel("editable label. Click me", editable=TRUE, container=g) visible(w) <- TRUE ## End(Not run)
## Not run: w <- gwindow("gformlayout", visible=FALSE) g <- gvbox(container=w) g$set_borderwidth(10) l1 <- glabel("static label", container=g) l2 <- glabel("bold label", container=g) font(l2) <- list(weight="bold") l3 <- glabel("editable label. Click me", editable=TRUE, container=g) visible(w) <- TRUE ## End(Not run)
The grid layout container uses matrix notation to position its
child components. This allows one to align widgets both
horizontally and vertically, as desired. There is some support for
matrix methods, such as dim
and [
to reference the
child objects.
The [
method for the grid layout allows one to reference
the child objects by index. The return value is non standard. It
may be the item, a list (if one dimensonaL) or an array. The list
format is convenient to refer to all the child objects in a
column.
The matrix notation allows for spanning of multiple rows and or columns, but no holes.
The ...
argument is used to pass in values for expand, fill, anchor (see
the add
method of ggroup
) for their meaning).
glayout( homogeneous = FALSE, spacing = 10, container = NULL, ..., toolkit = guiToolkit() ) .glayout(toolkit, homogeneous = FALSE, spacing = 10, container = NULL, ...) ## S3 method for class 'GLayout' x[i, j, ..., drop = TRUE] ## S3 replacement method for class 'GLayout' x[i ,j, ...] <- value
glayout( homogeneous = FALSE, spacing = 10, container = NULL, ..., toolkit = guiToolkit() ) .glayout(toolkit, homogeneous = FALSE, spacing = 10, container = NULL, ...) ## S3 method for class 'GLayout' x[i, j, ..., drop = TRUE] ## S3 replacement method for class 'GLayout' x[i ,j, ...] <- value
homogeneous |
are cells all the same size |
spacing |
between cell spacing |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
x |
object |
i |
row index |
j |
column index |
drop |
drop return type? |
value |
constructor for a widget using this object as the parent container |
gformlayout
for a more convenient means to layout forms.
## Not run: w <- gwindow("glayout example", visible=FALSE) g <- gvbox(container=w) lyt <- glayout(container=g) lyt[1,1] <- "a label" lyt[1,2] <- gedit("A widget", container=lyt) lyt[2, 1:2] <- gcombobox(state.name, cont=lyt) g1 <- ggroup(container=g) addSpring(g1) gbutton("values", container=g1, handler=function(h, ...) { print(sapply(lyt[,2], svalue)) }) visible(w) <- TRUE ## End(Not run)
## Not run: w <- gwindow("glayout example", visible=FALSE) g <- gvbox(container=w) lyt <- glayout(container=g) lyt[1,1] <- "a label" lyt[1,2] <- gedit("A widget", container=lyt) lyt[2, 1:2] <- gcombobox(state.name, cont=lyt) g1 <- ggroup(container=g) addSpring(g1) gbutton("values", container=g1, handler=function(h, ...) { print(sapply(lyt[,2], svalue)) }) visible(w) <- TRUE ## End(Not run)
Constructor for modal message dialog
generic for toolkit dispatch
gmessage( msg, title = "message", icon = c("info", "warning", "error", "question"), parent = NULL, ..., toolkit = guiToolkit() ) .gmessage(toolkit, msg, title = "message", icon = "", parent = NULL, ...)
gmessage( msg, title = "message", icon = c("info", "warning", "error", "question"), parent = NULL, ..., toolkit = guiToolkit() ) .gmessage(toolkit, msg, title = "message", icon = "", parent = NULL, ...)
msg |
Character. message to display. |
title |
Character. Title |
icon |
What icon to show |
parent |
Hint as to where to display |
... |
ignored |
toolkit |
toolkit |
gmessage
, gconfirm
,
gbasicdialog
, galert
The tabbed notebook container allows one to hold many different
pages with a mechanism – tabs – to switch between them. In
gWidgets2
new pages are added through the add
method. This is usually called implicitly in the child object's
constructor. One passes in the tab label through the extra
label
argument. Labels may be subsequently changed through
names<-
.
Children added to notebooks need a label, a position and optionally a close button (if supported). The arguments expand, fill, anchor are not specified – children expand and fill the allocated space.
Dispose deletes the current page, not the entire notebook
object. To delete a specific page, a combination of
svalue<-
and dispose
may be used.
The names
of a notebook are the page tab labels. These may
be retrieved and set through the names
method.
The notebook object contains pages referenced by index. This allows access to underlying page.
The change handler for the notebook is called when the page
changes. Tthe new page number is passed back in the page.no
component of 'h', which in some cases may differ from the value
given by svalue
within the handler call.
Dispose deletes the current page, not the entire notebook
object. To delete a specific page, a combination of
svalue<-
and dispose
may be used.
gnotebook(tab.pos = 3, container = NULL, ..., toolkit = guiToolkit()) .gnotebook(toolkit, tab.pos = 3, container = NULL, ...) ## S3 method for class 'GNotebook' add(obj, child, expand, fill, anchor, ...) ## S3 method for class 'GNotebook' dispose(obj, ...) ## S3 method for class 'GNotebook' names(x) ## S3 replacement method for class 'GNotebook' svalue(obj, index=TRUE, ...) <- value ## S3 method for class 'GNotebook' x[i, j, ..., drop = TRUE] ## S3 method for class 'GNotebook' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GStackWidget' dispose(obj, ...)
gnotebook(tab.pos = 3, container = NULL, ..., toolkit = guiToolkit()) .gnotebook(toolkit, tab.pos = 3, container = NULL, ...) ## S3 method for class 'GNotebook' add(obj, child, expand, fill, anchor, ...) ## S3 method for class 'GNotebook' dispose(obj, ...) ## S3 method for class 'GNotebook' names(x) ## S3 replacement method for class 'GNotebook' svalue(obj, index=TRUE, ...) <- value ## S3 method for class 'GNotebook' x[i, j, ..., drop = TRUE] ## S3 method for class 'GNotebook' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GStackWidget' dispose(obj, ...)
tab.pos |
integer. Position of tabs, 1 on bottom, 2 left, 3 top, 4 right. (If supported) |
container |
parent container |
... |
passed to |
toolkit |
underlying toolkit |
obj |
gnotebook object |
child |
some child component to add |
expand |
NULL or logical. For box containers controls whether a child will expand to fill the allocated space. |
fill |
NULL or character. For box containers. The value of |
anchor |
NULL or integer. For box containers. The anchor argument is used to position the child within the parent when there is more space allocated than the child requests. This is specified with a Cartesian pair in {-1,0,1} x {-1, 0, 1}. |
x |
notebook object svalue method Set the currently raised tab by index (the default) or name |
index |
|
value |
assignment value |
i |
row index. Either integer or character |
j |
ignored |
drop |
ignored |
handler |
handler |
action |
passed along to handler via |
none. called for its side effect.
In gWidgets2 the button arguments of the
gWidgets
constructor are removed. One passes the close
button request to the add
method.
To keep the signature the same as the generic, several arguments are passed in via ...:
A character. Label text for tab
An integer in 0
to length(obj)
indicating
the position to insert child. The new page is inserted to the
right of page number i
. When i=0
, the page appears
at the front, when i
is not specified it appears at the
end.
A logical. If TRUE
– and the toolkit
supports it – the page tab will include a close button.
gstackwidget
for a similar widget without
tabs.
## Not run: w <- gwindow("notebook example", visible=FALSE) nb <- gnotebook(container=w) gbutton("Page one", label="tab 1", container=nb) ## note label argument gbutton("Page two", label="tab 2", container=nb) svalue(nb) <- 1 addHandlerChanged(nb, handler=function(h,...) { message(sprintf("On page %s", h$page.no)) ## svalue(h$obj) not always right }) svalue(nb) <- 2 ## or use "Page two" dispose(nb) length(nb) ## End(Not run)
## Not run: w <- gwindow("notebook example", visible=FALSE) nb <- gnotebook(container=w) gbutton("Page one", label="tab 1", container=nb) ## note label argument gbutton("Page two", label="tab 2", container=nb) svalue(nb) <- 1 addHandlerChanged(nb, handler=function(h,...) { message(sprintf("On page %s", h$page.no)) ## svalue(h$obj) not always right }) svalue(nb) <- 2 ## or use "Page two" dispose(nb) length(nb) ## End(Not run)
A container for holding two child widgets where the space
allocated to each can be manipulated by the user with a pane
between the widgets, or programatticaly via svalue<-
. The
value specified to svalue<-
can be a number in $[0,1]$, in
which case it is a proportion or an integer, in which case it is a
pixel size (from the left or the top). The ambiguous case 1
or 1L
is determined by class. The value of svalue
is in proportion units.
gpanedgroup(horizontal = TRUE, container = NULL, ..., toolkit = guiToolkit()) .gpanedgroup(toolkit, horizontal = TRUE, container = NULL, ...)
gpanedgroup(horizontal = TRUE, container = NULL, ..., toolkit = guiToolkit()) .gpanedgroup(toolkit, horizontal = TRUE, container = NULL, ...)
horizontal |
direction of layout |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
Child widgets are added in the usual way, typically through the
container
argument of a constructor. Only two children may
be added. Children expand and fill the allocated space.
Setting the size is often only possible after the container
has been realized on the screen. In the example, this call of
svalue<-
is done after the parent window is made visible
for this reason. There were arguments to specify the children at
construction, but these have been removed.
## Not run: w <- gwindow("gpanedgroup", visible=FALSE) pg <- gpanedgroup(cont=w) gbutton("left", cont=pg) gbutton("right", cont=pg) visible(w) <- TRUE svalue(pg) <- 0.33 ## End(Not run)
## Not run: w <- gwindow("gpanedgroup", visible=FALSE) pg <- gpanedgroup(cont=w) gbutton("left", cont=pg) gbutton("right", cont=pg) visible(w) <- TRUE svalue(pg) <- 0.33 ## End(Not run)
Basic progress bar widget
S3 generic whose methods are implemented in the toolkit packages
gprogressbar(value = 10, container = NULL, ..., toolkit = guiToolkit()) .gprogressbar(toolkit, value, container, ...)
gprogressbar(value = 10, container = NULL, ..., toolkit = guiToolkit()) .gprogressbar(toolkit, value, container, ...)
value |
Initial value, between 0 and 100. A value of |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
a GButton
instance. While this object has its own
(reference) methods, one primarily interacts with it through S3
methods defined within the package.
## Not run: w <- gwindow("progress bar example") pb <- gprogressbar(cont=w) for(i in 10:100) {Sys.sleep(.1); svalue(pb) <- i} ## End(Not run)
## Not run: w <- gwindow("progress bar example") pb <- gprogressbar(cont=w) for(i in 10:100) {Sys.sleep(.1); svalue(pb) <- i} ## End(Not run)
A radio button group allows a user to select one from many
items. In gWidgets2 the radio button widget shows 2 or more
items. The items are coerced to characters, usually by the
underlying toolkit. Use the coerce_with
property to set a
function, such as as.numeric
, to coerce the return value
during the svalue
code. The items are referred to with the
[
method, the selected one with svalue
.
The svalue method returns the radio button label or its index if
index=TRUE
. Labels are coerced to character by many of the
toolkits. To be sure to return a numeric value, one can assign to
the coerce_with
property, e.g., obj$coerce_with <-
as.numeric
. For all widgets, if a function is specified to
coerce_with
it will be called on the value returned by
svalue
.
For a radio button group, for svalue
the value can be
referred to by index or label.
Check for repeated items before passing on to set_items
gradio( items, selected = 1, horizontal = FALSE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gradio( toolkit, items, selected = 1, horizontal = FALSE, handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GRadio' svalue(obj, index = NULL, drop = TRUE, ...) ## S3 replacement method for class 'GRadio' svalue(obj,index=NULL,drop=TRUE,...) <- value ## S3 replacement method for class 'GRadio' x[i, j, ...] <- value
gradio( items, selected = 1, horizontal = FALSE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gradio( toolkit, items, selected = 1, horizontal = FALSE, handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GRadio' svalue(obj, index = NULL, drop = TRUE, ...) ## S3 replacement method for class 'GRadio' svalue(obj,index=NULL,drop=TRUE,...) <- value ## S3 replacement method for class 'GRadio' x[i, j, ...] <- value
items |
items to select from |
selected |
index of initially selected item |
horizontal |
layout direction |
handler |
A handler assigned to the default change
signal. Handlers are called when some event triggers a widget to
emit a signal. For each widget some default signal is assumed, and
handlers may be assigned to that through Handlers may also be added via |
action |
User supplied data passed to the handler when it is called |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
obj |
object of method call |
index |
NULL or logical. If |
drop |
NULL or logical. If widget supports it, drop will work as it does in a data frame or perhaps someother means. |
value |
items to assigns a choices for the buttons |
x |
|
i |
button index. Leavel as missing to replace items to select from. |
j |
ignored |
if(interactive()) { w <- gwindow("Selection widgets") g <- gvbox(cont=w) fl <- gformlayout(cont=g) gcheckbox("checkbox", checked=TRUE, cont=fl, label="checkbox") gradio(state.name[1:4], selected=2, horizontal=TRUE, cont=fl, label="gradio") gcheckboxgroup(state.name[1:4], horizontal=FALSE, cont=fl, label="checkbox group") bg <- ggroup(cont=g) gbutton("ok", cont=bg, handler=function(h,...) print(sapply(fl$children, svalue))) }
if(interactive()) { w <- gwindow("Selection widgets") g <- gvbox(cont=w) fl <- gformlayout(cont=g) gcheckbox("checkbox", checked=TRUE, cont=fl, label="checkbox") gradio(state.name[1:4], selected=2, horizontal=TRUE, cont=fl, label="gradio") gcheckboxgroup(state.name[1:4], horizontal=FALSE, cont=fl, label="checkbox group") bg <- ggroup(cont=g) gbutton("ok", cont=bg, handler=function(h,...) print(sapply(fl$children, svalue))) }
The gseparator
widget provides a horizontal or vertical
line to visually divide child components of its parent
container. In addition to box containers this can be used within
toolbars (where one uses parent
and not container
).
gseparator(horizontal = TRUE, container = NULL, ..., toolkit = guiToolkit()) .gseparator(toolkit, horizontal = TRUE, container = NULL, ...)
gseparator(horizontal = TRUE, container = NULL, ..., toolkit = guiToolkit()) .gseparator(toolkit, horizontal = TRUE, container = NULL, ...)
horizontal |
Logical. Is separator drawn horizontally? |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
## Not run: w <- gwindow("Within page", visible=FALSE) g <- gvbox(container=w) glabel("Lorem ipsum ...", cont=g) gseparator(cont=g) bg <- ggroup(cont=g); addSpring(bg) gbutton("dismiss", container=bg, handler=function(h,...) dispose(w)) visible(w) <- TRUE w1 <- gwindow("within layout", visible=FALSE) lyt <- glayout(container=w1) lyt[1,1] <- "label" lyt[2,1:2] <- gseparator(container=lyt) lyt[3,2] <- "asdf" visible(w1) <- TRUE w2 <- gwindow("Within toolbar", visible=FALSE) l <- list(file=gaction("File", parent=w2), sep=gseparator(parent=w2), quit=gaction("quit", parent=w2)) gtoolbar(l, cont=w2) glabel("Lorem ipsum ...", container=w2) visible(w2) <- TRUE ## End(Not run)
## Not run: w <- gwindow("Within page", visible=FALSE) g <- gvbox(container=w) glabel("Lorem ipsum ...", cont=g) gseparator(cont=g) bg <- ggroup(cont=g); addSpring(bg) gbutton("dismiss", container=bg, handler=function(h,...) dispose(w)) visible(w) <- TRUE w1 <- gwindow("within layout", visible=FALSE) lyt <- glayout(container=w1) lyt[1,1] <- "label" lyt[2,1:2] <- gseparator(container=lyt) lyt[3,2] <- "asdf" visible(w1) <- TRUE w2 <- gwindow("Within toolbar", visible=FALSE) l <- list(file=gaction("File", parent=w2), sep=gseparator(parent=w2), quit=gaction("quit", parent=w2)) gtoolbar(l, cont=w2) glabel("Lorem ipsum ...", container=w2) visible(w2) <- TRUE ## End(Not run)
A slider widgets allows a selection from a range of numeric values. The widget presents the user with a quick to adjust, but relatively difficult to adjust precisely way to to pick a number.
gslider( from = 0, to = 100, by = 1, length.out = NULL, along.with = NULL, value = from[1], horizontal = TRUE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gslider( toolkit, from = 0, to = 100, by = 1, value = from, horizontal = TRUE, handler = NULL, action = NULL, container = NULL, ... )
gslider( from = 0, to = 100, by = 1, length.out = NULL, along.with = NULL, value = from[1], horizontal = TRUE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gslider( toolkit, from = 0, to = 100, by = 1, value = from, horizontal = TRUE, handler = NULL, action = NULL, container = NULL, ... )
from |
If a number of length one then a starting point, in
which case to, by are passed to |
to |
ending point when from is starting point |
by |
step size if not specified by |
length.out |
in place of by |
along.with |
in place of length.out |
value |
initial value |
horizontal |
Logical. Is separator drawn horizontally? |
handler |
A handler assigned to the default change
signal. Handlers are called when some event triggers a widget to
emit a signal. For each widget some default signal is assumed, and
handlers may be assigned to that through Handlers may also be added via |
action |
User supplied data passed to the handler when it is called |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
if(interactive()) { ## a range widget uses either a slider or a linked spinbutton to select a value w <- gwindow("Range widget", visible=FALSE) g <- ggroup(cont=w, horizontal=TRUE) sl <- gslider(from=0, to=100, by=1, value=0, cont=g, expand=TRUE, fill="both") sp <- gspinbutton(from=0, to=100, by=1, value=0, cont=g) ## Two ways to do this: ## addHandlerChanged(sl, function(...) svalue(sp) <- svalue(sl)) ## addHandlerChanged(sp, function(...) svalue(sl) <- svalue(sp)) f <- function(h, ...) svalue(h$action) <- svalue(h$obj) addHandlerChanged(sl, f, action=sp) addHandlerChanged(sp, f, action=sl) visible(w) <- TRUE }
if(interactive()) { ## a range widget uses either a slider or a linked spinbutton to select a value w <- gwindow("Range widget", visible=FALSE) g <- ggroup(cont=w, horizontal=TRUE) sl <- gslider(from=0, to=100, by=1, value=0, cont=g, expand=TRUE, fill="both") sp <- gspinbutton(from=0, to=100, by=1, value=0, cont=g) ## Two ways to do this: ## addHandlerChanged(sl, function(...) svalue(sp) <- svalue(sl)) ## addHandlerChanged(sp, function(...) svalue(sl) <- svalue(sp)) f <- function(h, ...) svalue(h$action) <- svalue(h$obj) addHandlerChanged(sl, f, action=sp) addHandlerChanged(sp, f, action=sl) visible(w) <- TRUE }
A spinbutton allows the user to select from a pre-selected range
of numbers. Similar to a slider, but with more precision, but
slower to adjust. The basic arguments mirror that of seq.int
.
gspinbutton( from = 0, to = 10, by = 1, length.out = NULL, along.with = NULL, value = from, digits = 0, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gspinbutton( toolkit, from = 0, to = 10, by = 1, value = from, digits = 0, handler = NULL, action = NULL, container = NULL, ... )
gspinbutton( from = 0, to = 10, by = 1, length.out = NULL, along.with = NULL, value = from, digits = 0, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gspinbutton( toolkit, from = 0, to = 10, by = 1, value = from, digits = 0, handler = NULL, action = NULL, container = NULL, ... )
from |
from value |
to |
to value |
by |
step length |
length.out |
number of steps. Only one of |
along.with |
Take from |
value |
initial value |
digits |
number of digits to display, should the toolkit support it |
handler |
A handler assigned to the default change
signal. Handlers are called when some event triggers a widget to
emit a signal. For each widget some default signal is assumed, and
handlers may be assigned to that through Handlers may also be added via |
action |
User supplied data passed to the handler when it is called |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
if(interactive()) { ## a range widget uses either a slider or a linked spinbutton to select a value w <- gwindow("Range widget", visible=FALSE) g <- ggroup(cont=w, horizontal=TRUE) sl <- gslider(from=0, to=100, by=1, value=0, cont=g, expand=TRUE, fill="both") sp <- gspinbutton(from=0, to=100, by=1, value=0, cont=g) ## Two ways to do this: ## addHandlerChanged(sl, function(...) svalue(sp) <- svalue(sl)) ## addHandlerChanged(sp, function(...) svalue(sl) <- svalue(sp)) f <- function(h, ...) svalue(h$action) <- svalue(h$obj) addHandlerChanged(sl, f, action=sp) addHandlerChanged(sp, f, action=sl) visible(w) <- TRUE }
if(interactive()) { ## a range widget uses either a slider or a linked spinbutton to select a value w <- gwindow("Range widget", visible=FALSE) g <- ggroup(cont=w, horizontal=TRUE) sl <- gslider(from=0, to=100, by=1, value=0, cont=g, expand=TRUE, fill="both") sp <- gspinbutton(from=0, to=100, by=1, value=0, cont=g) ## Two ways to do this: ## addHandlerChanged(sl, function(...) svalue(sp) <- svalue(sl)) ## addHandlerChanged(sp, function(...) svalue(sl) <- svalue(sp)) f <- function(h, ...) svalue(h$action) <- svalue(h$obj) addHandlerChanged(sl, f, action=sp) addHandlerChanged(sp, f, action=sl) visible(w) <- TRUE }
This widget is like a notebook – it holds a stack of pages, but does not provide the tabs to work with. Most methods are inherited from gnotebook's.
gstackwidget(container = NULL, ..., toolkit = guiToolkit()) .gstackwidget(toolkit, container = NULL, ...)
gstackwidget(container = NULL, ..., toolkit = guiToolkit()) .gstackwidget(toolkit, container = NULL, ...)
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
## Not run: w <- gwindow("stack widget", visible=FALSE) add_page <- function(cont, i) { g <- gvbox(container=cont) glabel(sprintf("page %s",i), container=g) bg <- ggroup(container=g); addSpring(bg) lb <- gbutton("Previous", container=bg, handler=function(h,...) { svalue(cont) <- max(1, i - 1) }) rb <- gbutton("Next", container=bg, handler=function(h,...) { svalue(cont) <- min(i + 1, length(cont)) }) } sw <- gstackwidget(cont=w) sapply(1:5, add_page, cont=sw) visible(w) <- TRUE ## End(Not run)
## Not run: w <- gwindow("stack widget", visible=FALSE) add_page <- function(cont, i) { g <- gvbox(container=cont) glabel(sprintf("page %s",i), container=g) bg <- ggroup(container=g); addSpring(bg) lb <- gbutton("Previous", container=bg, handler=function(h,...) { svalue(cont) <- max(1, i - 1) }) rb <- gbutton("Next", container=bg, handler=function(h,...) { svalue(cont) <- min(i + 1, length(cont)) }) } sw <- gstackwidget(cont=w) sapply(1:5, add_page, cont=sw) visible(w) <- TRUE ## End(Not run)
constructor to add a status bar to main window
generic for toolkit dispatch
gstatusbar(text = "", container = NULL, ..., toolkit = guiToolkit()) .gstatusbar(toolkit, text = "", container = NULL, ...)
gstatusbar(text = "", container = NULL, ..., toolkit = guiToolkit()) .gstatusbar(toolkit, text = "", container = NULL, ...)
text |
inital status text |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
## Not run: w <- gwindow("Statusbar", visible=FALSE) sb <- gstatusbar("status text", container=w) g <- gvbox(container=w) gbutton("update", container=g, handler=function(...) svalue(sb) <- "new value") visible(w) <- TRUE ## End(Not run)
## Not run: w <- gwindow("Statusbar", visible=FALSE) sb <- gstatusbar("status text", container=w) g <- gvbox(container=w) gbutton("update", container=g, handler=function(...) svalue(sb) <- "new value") visible(w) <- TRUE ## End(Not run)
The tabular widget allows a user to select one (or more) row(s)
using the mouse or keyboard selection. The selected rows are the
main property and are returned by svalue through their key (from
the column specified by chosen.col
), or by index. The
change handler changes on double-click event. Use add handler
click to respond to a change in selection.
For gtable one can pass in row(s) to select by index (when index=TRUE) or by match among the values in the chosen column. For setting by index, a value of 0L or integer(0) will clear the current selection
For GTable
objects the [
and [<-
methods are
(mostly) implemented. The [
method allows one to access the
object using the regular matrix notation (but there is no list
notation, e.g. $
or [[
, defined). The [<-
method is available, but for most toolkits is restricted: one can
not add columns, add rows, remove columns, remove rows, or change
the type of the column. For all of these actions, one can reassign
the items being displayed through the idiom obj[] <-
new_items
. This allows the widget to resize or redo the column
renderers.
The change handler for GTable
is called when the selection
changes. This is often the result of a click event (but need not
be), although we alias to addHandlerClicked
. For double
click events, see addHandlerDoubleclick
.
Double clicking is used to activate an item (single click is selection). We also bind pressing the Return key on an item to initiate this signal
For GTable
, visibility refers to which rows are currently
shown, not whether the widget itself is shown or hidden. (For the
latter, place the widget into a container and adjust that). One
can use this method to perform filtering by adjusting which rows
are displayed according to some criteria that returns a logical.
For GTable
the size<-
method is overridden to allow
one to specify the column widths. To do so, pass in the values for
width
, height
or column.widths
as named components
of a list. The value of column.widths
should be a numeric
vector of pixel widths of length matching the number of columns.
gtable( items, multiple = FALSE, chosen.col = 1, icon.col = NULL, tooltip.col = NULL, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gtable( toolkit, items, multiple = FALSE, chosen.col = 1, icon.col = NULL, tooltip.col = NULL, handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GTable' svalue(obj, index = NULL, ..., value) ## S3 method for class 'GTable' x[i, j, ..., drop = TRUE] ## S3 method for class 'GTable' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GTable' addHandlerDoubleclick(obj, handler, action = NULL, ...) ## S3 method for class 'GTable' visible(obj, ...) ## S3 replacement method for class 'GTable' size(obj) <- value
gtable( items, multiple = FALSE, chosen.col = 1, icon.col = NULL, tooltip.col = NULL, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gtable( toolkit, items, multiple = FALSE, chosen.col = 1, icon.col = NULL, tooltip.col = NULL, handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GTable' svalue(obj, index = NULL, ..., value) ## S3 method for class 'GTable' x[i, j, ..., drop = TRUE] ## S3 method for class 'GTable' addHandlerChanged(obj, handler, action = NULL, ...) ## S3 method for class 'GTable' addHandlerDoubleclick(obj, handler, action = NULL, ...) ## S3 method for class 'GTable' visible(obj, ...) ## S3 replacement method for class 'GTable' size(obj) <- value
items |
data.frame specifies items for selection. May be a vector, matrix or data frame |
multiple |
logical allow multiple selection |
chosen.col |
which value from the row is returned by selection |
icon.col |
NULL or integer. If latter, specifies column containing stock icon |
tooltip.col |
NULL or integer. If latter, specifies column containing tooltip |
handler |
A handler assigned to the default change
signal. Handlers are called when some event triggers a widget to
emit a signal. For each widget some default signal is assumed, and
handlers may be assigned to that through Handlers may also be added via |
action |
User supplied data passed to the handler when it is called |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
obj |
object of method call |
index |
NULL or logical. If |
value |
value to assign for selection or property |
x |
|
i |
row index |
j |
column index |
drop |
do we drop when subsetting |
Many generic methods for data frames are implemented for
gtable
. These include [
, [<-
, length
,
names
, and names<-
Returns an object of class GTable
## Not run: w <- gwindow("gtable example", visible=FALSE) g <- gvbox(cont=w) tbl <- gtable(mtcars, cont=g, expand=TRUE, fill=TRUE) addHandlerClicked(tbl, handler=function(h,...) sprintf("You selected %s", svalue(h$obj))) visible(w) <- TRUE ## End(Not run)
## Not run: w <- gwindow("gtable example", visible=FALSE) g <- gvbox(cont=w) tbl <- gtable(mtcars, cont=g, expand=TRUE, fill=TRUE) addHandlerClicked(tbl, handler=function(h,...) sprintf("You selected %s", svalue(h$obj))) visible(w) <- TRUE ## End(Not run)
The multiline text widget has its main property the text contained within.
The svalue
will return a string (length-1 character
vector) with embedded newlines
The "change" handler is addHandlerKeystroke
Use addHandlerSelectionChanged
to monitor the selection
The svalue
method for a gtext object returns a) the buffers
content; b) the selected text (if drop=TRUE
, but not
NULL
), this can be used to set the selected value, as well;
c) the index of the selection if index=TRUE
.
gtext( text = NULL, width = NULL, height = 300, font.attr = NULL, wrap = TRUE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gtext( toolkit, text = NULL, width = NULL, height = 300, font.attr = NULL, wrap = TRUE, handler = NULL, action = NULL, container = NULL, ... ) insert( obj, value, where = c("end", "beginning", "at.cursor"), font.attr = NULL, do.newline = TRUE, ... ) ## S3 method for class 'GText' insert( obj, value, where = c("end", "beginning", "at.cursor"), font.attr = NULL, do.newline = TRUE, ... ) ## S3 method for class 'GText' dispose(obj, ...) ## S3 method for class 'GText' svalue(obj, index = NULL, drop = NULL, ...)
gtext( text = NULL, width = NULL, height = 300, font.attr = NULL, wrap = TRUE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gtext( toolkit, text = NULL, width = NULL, height = 300, font.attr = NULL, wrap = TRUE, handler = NULL, action = NULL, container = NULL, ... ) insert( obj, value, where = c("end", "beginning", "at.cursor"), font.attr = NULL, do.newline = TRUE, ... ) ## S3 method for class 'GText' insert( obj, value, where = c("end", "beginning", "at.cursor"), font.attr = NULL, do.newline = TRUE, ... ) ## S3 method for class 'GText' dispose(obj, ...) ## S3 method for class 'GText' svalue(obj, index = NULL, drop = NULL, ...)
text |
initial text |
width |
width of widget |
height |
height of widget (when width is specified) |
font.attr |
font attributes for text buffer. One can also specify font attributes for insertion. The font attributes are specified with a list with named components, with names and values coming from:
|
wrap |
logical do lines wrap |
handler |
A handler assigned to the default change
signal. Handlers are called when some event triggers a widget to
emit a signal. For each widget some default signal is assumed, and
handlers may be assigned to that through Handlers may also be added via |
action |
User supplied data passed to the handler when it is called |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
obj |
object |
value |
text to insert |
where |
position of insertion |
do.newline |
logical add a newline at end |
index |
NULL or logical. If |
drop |
NULL or logical. If widget supports it, drop will work as it does in a data frame or perhaps someother means. |
called for side effect
with gWidgetstcltk the allocation of size to the
widget may be incorrect. It is best to wait until the widget is
added before displaying its parent window. See the visible
argument for gwindow
.
## Not run: w <- gwindow("gtext example", visible=FALSE) g <- gvbox(cont=w) t1 <- gtext("initial text", container=g) t2 <- gtext("monospace", font.attr=list(family="monospace"), container=g) insert(t2, "new text in bold", font.attr=list(weight="bold")) visible(w) <- TRUE ## End(Not run)
## Not run: w <- gwindow("gtext example", visible=FALSE) g <- gvbox(cont=w) t1 <- gtext("initial text", container=g) t2 <- gtext("monospace", font.attr=list(family="monospace"), container=g) insert(t2, "new text in bold", font.attr=list(weight="bold")) visible(w) <- TRUE ## End(Not run)
Calls FUN every ms/1000 seconds. A timer is stopped through its stop_timer
method which is called using OO style: obj$stop_timer()
.
gtimer( ms, FUN, data = NULL, one.shot = FALSE, start = TRUE, toolkit = guiToolkit() ) .gtimer(toolkit, ms, FUN, data = NULL, one.shot = FALSE, start = TRUE)
gtimer( ms, FUN, data = NULL, one.shot = FALSE, start = TRUE, toolkit = guiToolkit() ) .gtimer(toolkit, ms, FUN, data = NULL, one.shot = FALSE, start = TRUE)
ms |
interval in milliseconds |
FUN |
FUnction to call. Has one argument, data passed in |
data |
passed to function |
one.shot |
logical. If TRUE, called just once, else repeats |
start |
logical. If FALSE, started by |
toolkit |
gui toolkit to dispatch into |
## Not run: i <- 0 FUN <- function(data) {i <<- i + 1; if(i > 10) a$stop_timer(); print(i)} a <- gtimer(1000, FUN) ## ## a one shot timer is run only once FUN <- function(data) message("Okay, I can breathe now") hold_breath <- gtimer(1000*60, FUN, one.shot=TRUE) ## End(Not run)
## Not run: i <- 0 FUN <- function(data) {i <<- i + 1; if(i > 10) a$stop_timer(); print(i)} a <- gtimer(1000, FUN) ## ## a one shot timer is run only once FUN <- function(data) message("Okay, I can breathe now") hold_breath <- gtimer(1000*60, FUN, one.shot=TRUE) ## End(Not run)
A toolbar can be added to a main window to proxy various
actions. Toolbars can also contain various widgets, such as
buttons, checkboxes, radio buttons, etc. These should be
constructed using a parent
argument – not a
container
argument. In gWidgets2 a toolbar is
specified by a list of toolbar items. The svalue
and
svalue<-
methods may be used to get or set the items.
A toolbar item is a list of action items or a toolbar instance
for a toolbar, svalue<-
replaces the toolbar items with new ones specified by value.
gtoolbar( toolbar.list = list(), style = c("both", "icons", "text", "both-horiz"), container = NULL, ..., toolkit = guiToolkit() ) .gtoolbar( toolkit, toolbar.list = list(), style = c("both", "icons", "text", "both-horiz"), container = NULL, ... ) ## S3 method for class 'GToolBar' add(obj, child, expand = FALSE, fill = NULL, anchor = NULL, ...) ## S3 replacement method for class 'GToolBar' svalue(obj, index=NULL, ...) <- value
gtoolbar( toolbar.list = list(), style = c("both", "icons", "text", "both-horiz"), container = NULL, ..., toolkit = guiToolkit() ) .gtoolbar( toolkit, toolbar.list = list(), style = c("both", "icons", "text", "both-horiz"), container = NULL, ... ) ## S3 method for class 'GToolBar' add(obj, child, expand = FALSE, fill = NULL, anchor = NULL, ...) ## S3 replacement method for class 'GToolBar' svalue(obj, index=NULL, ...) <- value
toolbar.list |
list. A one-level list of |
style |
style for icon or text. |
container |
a GWindow instance |
... |
ignored |
toolkit |
toolkit |
obj |
parent object |
child |
child widget |
expand |
NULL or logical. For box containers controls whether a child will expand to fill the allocated space. |
fill |
NULL or character. For box containers. The value of |
anchor |
NULL or integer. For box containers. The anchor argument is used to position the child within the parent when there is more space allocated than the child requests. This is specified with a Cartesian pair in {-1,0,1} x {-1, 0, 1}. |
index |
NULL or logical. If |
value |
value to assign for selection or property |
Which toolkit are we using?
gtoolkit()
gtoolkit()
string of toolkit (RGtk2, tcltk, Qt, ???)
The gtree
widget is used to present structured heirarchical
data. This data may be specified through a data frame with some
accompanying columns by which to split the data, or dynamically
through a function (offspring
).
For a GTree
object, svalue refers to the path specified as
a vector of keys or (if INDEX=TRUE
) by an integer vector
of offspring positions. The drop
argument is used to
indicate if the terminus of the path is returned or the entire
path, defaults=TRUE. To get the data associated with a row, use the [
method.
For a GTree
object, svalue refers to the path specified as
a vector of keys . For the assignment method, one assigns by
index. That is svalue(tr, index=TRUE) <- svalue(tr,
index=TRUE)
should not change the state of the widget. (The
index=TRUE
argument is the case for setting, but not
getting.)
The [
method is used to return the data associated with a
selected row. The svalue
method returns the path or its
endpoint, the [
method returns the row data associated with
the path.
The update method for GTree
recomputes the base nodes, then reopens the given node if still available
gtree( x = NULL, INDICES = NULL, offspring = x, offspring.data = NULL, chosen.col = 1, offspring.col = 2, icon.col = NULL, tooltip.col = NULL, multiple = FALSE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gtree( toolkit, offspring = NULL, offspring.data = NULL, chosen.col = 1, offspring.col = 2, icon.col = NULL, tooltip.col = NULL, multiple = FALSE, handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GTree' svalue(obj, index = FALSE, drop = TRUE, ...) ## S3 replacement method for class 'GTree' svalue(obj, index=TRUE, ...) <- value ## S3 method for class 'GTree' x[i, j, ..., drop = FALSE] ## S3 method for class 'GTree' update(object, ...)
gtree( x = NULL, INDICES = NULL, offspring = x, offspring.data = NULL, chosen.col = 1, offspring.col = 2, icon.col = NULL, tooltip.col = NULL, multiple = FALSE, handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() ) .gtree( toolkit, offspring = NULL, offspring.data = NULL, chosen.col = 1, offspring.col = 2, icon.col = NULL, tooltip.col = NULL, multiple = FALSE, handler = NULL, action = NULL, container = NULL, ... ) ## S3 method for class 'GTree' svalue(obj, index = FALSE, drop = TRUE, ...) ## S3 replacement method for class 'GTree' svalue(obj, index=TRUE, ...) <- value ## S3 method for class 'GTree' x[i, j, ..., drop = FALSE] ## S3 method for class 'GTree' update(object, ...)
x |
Data frame. Optional, if given specify INDICES value to split data into heirarchical data structure |
INDICES |
Integers or column names, referring to columns of |
offspring |
function. A function passed values |
offspring.data |
Passed to second argument of |
chosen.col |
integer or one of column names of data frame
returned by |
offspring.col |
integer or column name. Points to column containing logical values indicating if a row has offspring. |
icon.col |
integer of one of the column names of the data frame. If provided (non-NULL), then this column should provide a stock icon name to be placed in the row for the given data. |
tooltip.col |
integer or one of the column names of the data frame. If provided (non-NULL), then the row for this item will have a tooltip given by the pointed to value. |
multiple |
logical. Is multiple selection allowed? |
handler |
A handler assigned to the default change
signal. Handlers are called when some event triggers a widget to
emit a signal. For each widget some default signal is assumed, and
handlers may be assigned to that through Handlers may also be added via |
action |
User supplied data passed to the handler when it is called |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
passed to update method |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
obj |
object |
index |
index |
drop |
do we return tip or path |
value |
vector of indices |
i |
ignored |
j |
ignored |
object |
object to update |
In the former case, the data frame is split up by the columns
specified by INDICES. The first index is used to give the intial
branches, the second index the second, etc. The end leaves are the
data associated with a given path, with key given by that column
specified by chosen.col
For the latter case, the "path" of the current node (the node and
its ancestors) is passed to the offspring
function which
computes the next level in the heirarchy. This level is specified
through a data frame. This data frame has special columns. The
chosen.col
specifies which column is used as the key in the
path, the icon.col
(when given) points to a stock icon name
to decorate the column. Similarly, the tooltip.columns
. The
fact that a row in the data frame has offspring is specified
through the offspring.col
column, again specifed by index
or column name.
################################################## ## This tree reads a list offspring <- function(path=character(0), lst, ...) { if(length(path)) obj <- lst[[path]] else obj <- lst nms <- names(obj) hasOffspring <- sapply(nms, function(i) { newobj <- obj[[i]] is.recursive(newobj) && !is.null(names(newobj)) }) data.frame(comps=nms, hasOffspring=hasOffspring, ## fred=nms, stringsAsFactors=FALSE) } l <- list(a="1", b= list(a="21", b="22", c=list(a="231"))) ## Not run: w <- gwindow("Tree test") t <- gtree(offspring=offspring, offspring.data=l, cont=w) ## End(Not run) ################################################## ## This tree looks at recursive objects describe <- function(x) UseMethod("describe") describe.default <- function(x) sprintf("An object with class %s", class(x)[1]) describe.integer <- function(x) sprintf("An integer with %s value%s", length(x), ifelse(length(x) > 1, "s", "")) describe.numeric <- function(x) sprintf("A numeric with %s value%s", length(x), ifelse(length(x) > 1, "s", "")) describe.factor <- function(x) sprint("A factor with %s level%s", length(levels(x)), ifelse(length(levels(x)) > 1, "s", "")) offspring <- function(path, obj) { if(length(path) > 0) x <- obj[[path]] else x <- obj nms <- names(x) recursive <- sapply(x, function(i) { is.recursive(i) && !is.null(attr(i, "names")) && length(i) > 0 }) descr <- sapply(x, describe) data.frame(Variable=nms, offspring=recursive, Description=descr, stringsAsFactors=FALSE) } l <- lm(mpg ~ wt, mtcars) ## Not run: w <- gwindow("test") gtree(offspring=offspring, offspring.data=l, cont=w) ## End(Not run)
################################################## ## This tree reads a list offspring <- function(path=character(0), lst, ...) { if(length(path)) obj <- lst[[path]] else obj <- lst nms <- names(obj) hasOffspring <- sapply(nms, function(i) { newobj <- obj[[i]] is.recursive(newobj) && !is.null(names(newobj)) }) data.frame(comps=nms, hasOffspring=hasOffspring, ## fred=nms, stringsAsFactors=FALSE) } l <- list(a="1", b= list(a="21", b="22", c=list(a="231"))) ## Not run: w <- gwindow("Tree test") t <- gtree(offspring=offspring, offspring.data=l, cont=w) ## End(Not run) ################################################## ## This tree looks at recursive objects describe <- function(x) UseMethod("describe") describe.default <- function(x) sprintf("An object with class %s", class(x)[1]) describe.integer <- function(x) sprintf("An integer with %s value%s", length(x), ifelse(length(x) > 1, "s", "")) describe.numeric <- function(x) sprintf("A numeric with %s value%s", length(x), ifelse(length(x) > 1, "s", "")) describe.factor <- function(x) sprint("A factor with %s level%s", length(levels(x)), ifelse(length(levels(x)) > 1, "s", "")) offspring <- function(path, obj) { if(length(path) > 0) x <- obj[[path]] else x <- obj nms <- names(x) recursive <- sapply(x, function(i) { is.recursive(i) && !is.null(attr(i, "names")) && length(i) > 0 }) descr <- sapply(x, describe) data.frame(Variable=nms, offspring=recursive, Description=descr, stringsAsFactors=FALSE) } l <- lm(mpg ~ wt, mtcars) ## Not run: w <- gwindow("test") gtree(offspring=offspring, offspring.data=l, cont=w) ## End(Not run)
set or get the current toolkit for gWidgets
guiToolkit(name = NULL)
guiToolkit(name = NULL)
name |
name of toolkit (e.g. "tcltk", "RGtk2", "Qt" (not
qtbase)). If NULL, then we search for it in a) an iherited toolkit
object b) the "guiToolkit" option (which can be set via
In design this is to allow different toolkits to be used with different GUIs, but due to differences in event loops, this often leads to lockups, so is not recommended. |
an instance of guiWidgetsToolkit sub class.
An observer can be observed
This interface is inherited by the base GComponent classes in the
toolkit implementations. The methods defined here are referenced
by the S3 methods. For exampe, svalue
dispatches to
get_value
or get_index
.
Class for commands. Has methods do, redo, undo
A list with ptr. delegates call of do or undo to appropriate command
A reference class to create a model that monitors the global
workspace. The class has method update_state
and the
"getting" methods get_by_class
, get_by_function
(filter), get_changes
. Use with a gtimer
instance to
keep up to date with changes to the workspace.
... |
passed to constructor |
We combine both widget and container methods here. It isn't perfect, but they do share quite a bit. Perhaps, we could make the container class subclass the basic interface.
update(...)
Call self.
update(...)
Call self.
add_observer(o, signal = "DEFAULT")
Add an observer. Return id for block/remove/...
block_observer(id)
Block observers. If o missing, block all
block_observers()
Block all observers
notify_observers(..., signal = "DEFAULT")
Call each non-blocked observer
remove_observer(id)
Remove observer
unblock_observer(id)
Unblock observer. If id missing, unblock global block
unblock_observers()
Remove block of all observers. Keeps count, so may need to call again
add_handler(signal, handler, action, ...)
Add a handler to be called for the event indicated by signal
get_enabled()
is widget sensistive to user input
get_index(drop = NULL, ...)
svalue; index=TRUE
get_value(drop = NULL, ...)
Get main value of widget. From 'svalue' when index = FALSE or NULL
set_enabled(value, ...)
specify with logical if widget is sensistive to user input
set_value(value, ..., drop = NULL)
for 'svalue<-' when index = FALSE or NULL
any_changes(...)
Report if any changes
filter_names(f)
Filter the names by f
get_by_class(classes = character(0))
Return objects matching any of classes
get_by_function(f)
Filter objects by function f
get_changes()
Return list of changes
initialize(...)
Initialze state of cached objects
pop_changes()
pop changes, reset
update_state(...)
update cache of names/digests, then notify observers if there are changes
A workspace browser widget. The workspace browser displays values in the global environment. Displayed objects are shown in categories.
Return selected objects a string (when drop=TRUE
) with
recursive values separated by $
, or the objects themselves (when drop=FALSE
).
gvarbrowser( handler = NULL, action = "summary", container = NULL, ..., toolkit = guiToolkit() ) .gvarbrowser( toolkit, handler = NULL, action = "summary", container = NULL, ... ) ## S3 method for class 'GVarBrowser' svalue(obj, index = FALSE, drop = TRUE, ...)
gvarbrowser( handler = NULL, action = "summary", container = NULL, ..., toolkit = guiToolkit() ) .gvarbrowser( toolkit, handler = NULL, action = "summary", container = NULL, ... ) ## S3 method for class 'GVarBrowser' svalue(obj, index = FALSE, drop = TRUE, ...)
handler |
A handler assigned to the default change
signal. Handlers are called when some event triggers a widget to
emit a signal. For each widget some default signal is assumed, and
handlers may be assigned to that through Handlers may also be added via |
action |
User supplied data passed to the handler when it is called |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
obj |
object of method call |
index |
NULL or logical. If |
drop |
NULL or logical. If widget supports it, drop will work as it does in a data frame or perhaps someother means. |
For defining the categories, the reference method set_filter_classes
takes a named list, the names defining the categories, the values
being the classes belonging to that category. Non categorized
values appear separately. The default is defined in
gWidgets2:::gvarbrowser_default_classes
.
The variable browser uses an instance of WSWatcherModel
to
monitor the global workspace. This instance may be useful for
other purposes. (For example, one may add an observer that is
called to listen for changes to the set of available data
frames.). The instance is available through the ws_model
property.
The svalue
method returns the selected variable names. If
drop=FALSE
is given, the objects are returned.
The widget should support dragging from without needing to specify
a drag_source
, though this may be overridden.
Use addHandlerChanged
to listen to activation of a variable
(double clicking). Use addHandlerSelectionChanged
to
monitor change of selection.
Used as template for documentation
gwidget( handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() )
gwidget( handler = NULL, action = NULL, container = NULL, ..., toolkit = guiToolkit() )
handler |
A handler assigned to the default change
signal. Handlers are called when some event triggers a widget to
emit a signal. For each widget some default signal is assumed, and
handlers may be assigned to that through Handlers may also be added via |
action |
User supplied data passed to the handler when it is called |
container |
A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.) |
... |
These values are passed to the |
toolkit |
Each widget constructor is passed in the toolkit it
will use. This is typically done using the default, which will
lookup the toolkit through |
top-level window object
Dispatches on type of child (menubar, toolbar, statusbar, widget)
The dispose
method destroys the top-level window and its children.
gwindow( title = "Window", visible = TRUE, name = title, width = NULL, height = NULL, parent = NULL, handler = NULL, action = NULL, ..., toolkit = guiToolkit() ) .gwindow( toolkit, title, visible, name, width, height, parent, handler, action, ... ) ## S3 method for class 'GWindow' add(obj, child, expand = NULL, fill = NULL, anchor = NULL, ...) ## S3 method for class 'GWindow' dispose(obj, ...)
gwindow( title = "Window", visible = TRUE, name = title, width = NULL, height = NULL, parent = NULL, handler = NULL, action = NULL, ..., toolkit = guiToolkit() ) .gwindow( toolkit, title, visible, name, width, height, parent, handler, action, ... ) ## S3 method for class 'GWindow' add(obj, child, expand = NULL, fill = NULL, anchor = NULL, ...) ## S3 method for class 'GWindow' dispose(obj, ...)
title |
title for window's title bar. This is the main
property and is accessed via |
visible |
logical. If |
name |
Name for registry of windows |
width |
initial width of window |
height |
initial height of window. This sets height before window manager manages the window |
parent |
If non-NULL, can be used to suggest default location of window. The argument name was changed from location to parent. This can be a coordinate pair (x,y) with (0,0) the upper left corner, or a gwindow instance. In the latter case the location is suggested by the location of the current window. This is useful for placing dialogs near the parent window. |
handler |
handler for destroy event |
action |
action passed t handler |
... |
ignored |
toolkit |
toolkit |
obj |
parent object |
child |
child widget |
expand |
NULL or logical. For box containers controls whether a child will expand to fill the allocated space. |
fill |
NULL or character. For box containers. The value of |
anchor |
NULL or integer. For box containers. The anchor argument is used to position the child within the parent when there is more space allocated than the child requests. This is specified with a Cartesian pair in {-1,0,1} x {-1, 0, 1}. |
a GWindow
instance
john verzani
put in so can be updated easily
installing_gWidgets_toolkits()
installing_gWidgets_toolkits()
is value missing, null, 0-length or NA length 1
is_empty(x)
is_empty(x)
x |
object to test |
logical
Return logical indicating if we are on a macintosh machine
is_MacOSX()
is_MacOSX()
logical
Return logical indicating if we are on a Windows machine
is_Windows()
is_Windows()
logical
Widgets can be destroyed, but their R object is still present. This is FALSE in that case.
isExtant(obj) ## Default S3 method: isExtant(obj)
isExtant(obj) ## Default S3 method: isExtant(obj)
obj |
object |
constructor for handler object
observer(receiver, handler, action = NULL)
observer(receiver, handler, action = NULL)
receiver |
object receiving event |
handler |
function to call |
action |
used to parametrize handler call not exported, call using ::: |
Some widgets support redo actions
redo(obj, ...) ## S3 method for class 'GComponent' redo(obj, ...)
redo(obj, ...) ## S3 method for class 'GComponent' redo(obj, ...)
obj |
object to redo |
... |
ignored |
Provide a short summary for an object
method for generic
method for generic
method for generic
method for generic
method for generic
method for generic
method for generic
method for generic
method for generic
short_summary(x) ## Default S3 method: short_summary(x) ## S3 method for class 'numeric' short_summary(x) ## S3 method for class 'character' short_summary(x) ## S3 method for class 'logical' short_summary(x) ## S3 method for class 'data.frame' short_summary(x) ## S3 method for class 'matrix' short_summary(x) ## S3 method for class 'list' short_summary(x) ## S3 method for class 'lm' short_summary(x) ## S3 method for class ''function'' short_summary(x)
short_summary(x) ## Default S3 method: short_summary(x) ## S3 method for class 'numeric' short_summary(x) ## S3 method for class 'character' short_summary(x) ## S3 method for class 'logical' short_summary(x) ## S3 method for class 'data.frame' short_summary(x) ## S3 method for class 'matrix' short_summary(x) ## S3 method for class 'list' short_summary(x) ## S3 method for class 'lm' short_summary(x) ## S3 method for class ''function'' short_summary(x)
x |
object |
The size is specified in pixels (integers). Some toolkits allow -1 as a default, but not all.
size(obj) ## Default S3 method: size(obj) size(obj) <- value size(obj) <- value
size(obj) ## Default S3 method: size(obj) size(obj) <- value size(obj) <- value
obj |
object |
value |
size in pixels |
This returns the "selected" value in a widget (if applicable), or
its main property. Selection varies from widget to widget, but
should generally be what can be added to the widget by mouse click
or typing. For some widgets, the extra argument index=TRUE
will return the index of the selected value, not the value. For
some widget, the argument drop
is given to either prevent
or encourage dropping of information.
Calls coerce_with
when available. This value is a function
and may be set as any property if the constructor does not
explicity provide it.
This method sets the selected value of, or main property of the widget.
For gformlayout
the svalue
assigment method takes a
named list and calls svalue<-
on the children with matching
names.
svalue(obj, index = FALSE, drop = NULL, ...) ## Default S3 method: svalue(obj, index = NULL, drop = NULL, ...) svalue(obj, index=NULL, ...) <- value svalue(obj, index=NULL, ...) <- value ## S3 replacement method for class 'GFormLayout' svalue(obj, index=NULL, ...) <- value
svalue(obj, index = FALSE, drop = NULL, ...) ## Default S3 method: svalue(obj, index = NULL, drop = NULL, ...) svalue(obj, index=NULL, ...) <- value svalue(obj, index=NULL, ...) <- value ## S3 replacement method for class 'GFormLayout' svalue(obj, index=NULL, ...) <- value
obj |
object of method call |
index |
NULL or logical. If |
drop |
NULL or logical. If widget supports it, drop will work as it does in a data frame or perhaps someother means. |
... |
passed on to call |
value |
value to assign for selection or property |
THe return value varies, depending if the widget is a
"selection" widget or not. For non-selection widgets, the main
property is loosely defined (the title of a window, text of a
label or button, spacing of box containers, ...). For selection
widgets the return value is the currently selected value. If no
selection is made, this will be a 0-length vector with the
expected class, if possible. For selection widgets, when
index=TRUE
, the value is an integer, possible 0-length when
non selection is made.
Unlike attr<-
, this method (essentially) stores the
attribute in a reference to the object, not a copy. As such it can
be used within function call (handlers) to assign values outside
the scope of the function call.
tag(obj, key) ## Default S3 method: tag(obj, key) tag(obj, key) <- value tag(obj, key) <- value
tag(obj, key) ## Default S3 method: tag(obj, key) tag(obj, key) <- value tag(obj, key) <- value
obj |
object |
key |
character. Values are stored by key. If missing, all keys are returned. |
value |
to assign to key |
Get a tooltip for the widget
Basic S3 method for tooltip<-
Set a tooltip for the widget
Basic S3 method for tooltip<-
tooltip(obj) ## Default S3 method: tooltip(obj) tooltip(obj) <- value tooltip(obj) <- value
tooltip(obj) ## Default S3 method: tooltip(obj) tooltip(obj) <- value tooltip(obj) <- value
obj |
object |
value |
character tooltip value |
Some widgets support undo actions. See reference class method can_undo
as well.
undo(obj, ...) ## S3 method for class 'GComponent' undo(obj, ...)
undo(obj, ...) ## S3 method for class 'GComponent' undo(obj, ...)
obj |
object to call undo on |
... |
ignored |
For most – but not all – widgets, a widget is visible if it is shown. For others, parts of the widget may be controlled by visible. If the former state is desired, simply place widget into a box container.
visible(obj, ...) ## Default S3 method: visible(obj, ...) visible(obj) <- value visible(obj) <- value
visible(obj, ...) ## Default S3 method: visible(obj, ...) visible(obj) <- value visible(obj) <- value
obj |
object |
... |
ignored |
value |
logical. Set visible state. |
Functions to message something needs doing. Easy to search for
XXX(msg)
XXX(msg)
msg |
optional message to emit |