gwindow: Main window constructor

Description Usage Arguments Details Value Methods Examples

View source: R/gwindow.R

Description

There can be more than one gwindow instance per script, but one is special. This one is called without a parent object, which otherwise is typically another gwindow instance. The special window sets up the environment to store the callbacks etc. Subwindows are possible. Simply pass a value of NULL to the argument renderTo. This argument is used to specify the DOM id of a DIV tag. If given, the GUI created by the gwindow call will replace this part of the web page. If not given, then a subwindow will be rendered. The visible<- method can be used to recompute the layout. This is often useful as the last line of a script.

The GWindow class is used for windows and subwindows. Windows in gWidgetsWWW2 are rendered to parts of the web page. In the simplest case, they are rendered to the document body and are the only thing the user sees. However, one can render to parts of a window as well. This is why we have a renderTo argument in the constructor.

Usage

1
2
gwindow(title = "", parent = NULL, handler = NULL, action = NULL, ...,
  renderTo = NULL, width = NULL, height = NULL, ext.args = NULL)

Arguments

title

Window title

parent

One and only one gwindow per script should have no parent specified. Otherwise, this should be a gwindow instance.

handler

Handler called when window is closed. (For subwindows only)

action

action passed to handler

...

ignored

renderTo

Where to render window. For subwindows, this should be NULL. For main windows, this can be a DOM id or left as NULL, in which case the entire web page is used.

width

width of a subwindow in pixels.

height

height of a subwindow in pixels

ext.args

extra args passed to the constructor

Details

One of the instances on a page contains the "toplevel" object, which routes handler requests and gives web page responses.

Subwindows are floating windows that appear on top of the web page, like a dialog box.

The method start_comet will launch a long-poll process, whereby the browser repeatedly queries the server for any changes. This can be useful if one expects to launch a long-running process and the handler that initiates this will time out before the process is done. One needs only to add the javascript commands to the queue.

Value

An ExtContainer object

Methods

do_layout()

Call layout method of container to recompute

dump()

Display js_queue for debugging

get_value(...)

Get main property, Can't query widget, so we store here

set_value(value, ...)

Set main property, invoke change handler on change

set_visible(value)

Show container and its siblings

start_comet()

Turn on long-poll process for passing in commands from server

Examples

1
2
3
4
5
6
7
8
w <- gwindow("Top level", renderTo="replaceme") ## no parent, so main one
g <- ggroup(cont=w)
b <- gbutton("click me for a subwindow", cont=g, handler=function(h,...) {
  w1 <- gwindow("subwindow -- no renderTo", renderTo=NULL, parent=w)
  g <- ggroup(cont=w1)
  gbutton("dispose", cont=g, handler=function(h,...) dispose(w1))
})
w2 <- gwindow("render elsewhere", parent=w, renderTo="replacemetoo") ## renderst to part of page

jverzani/gWidgetsWWW2 documentation built on Feb. 9, 2020, 5:18 p.m.