Package bw :: Package aphrodite :: Module web :: Class widgets
[frames] | no frames]

Class widgets

object --+
         |
        widgets

This class contains helper functions for creating AXML Widgets

Instance Methods

Inherited from object: __delattr__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Methods
 
input_tag(c, id, validator=None, autocomplete=None, **kwargs)
Create an input widget capable of textual input, validations and autocompletion.
 
datepicker_tag(c, id, validator=None, **kwargs)
 
grid_tag(c, id, **kwargs)
Create a grid
 
notification_tag(c, msg, **kwargs)
 
chart_tag(c, id, ch_type, width, height, columns, **kwargs)
Render a chart using an IFRAME
Class Variables
  input_attributes = 'type', 'name', 'value', 'size', 'maxlength...
  data_keys = 'url', 'data', 'reader', 'fields', 'datalength'
  grid_keys = 'pagesize', 'columns', 'groupby', 'filterable', 's...
  notification_keys = 'delay', 'duration', 'width', 'height', 'i...
  LINE_CHART = "lc"
  LINE_GRAPH = "lxy"
  SPARKLINES = "ls"
  BAR_HORIZONTAL = "bhs"
  BAR_VERTICAL = "bvs"
  PIE_2D = "p"
  PIE = "p"
  PIE_3D = "p3"
  SCATTERPLOT = "s"
Properties

Inherited from object: __class__

Method Details

input_tag(c, id, validator=None, autocomplete=None, **kwargs)
Class Method

 

Create an input widget capable of textual input, validations and autocompletion. Keyword arguments which are applicable to input tags are passed through. Other keyword arguments are sent to the Javascript widget.

Parameters:
  • id - The id of the widget
  • name - The name of the widget. Default: same as id
  • type - The type of the input tag (text/password/button/checkbox/radio/image etc.). Default: text
  • validator - A single or list of strings which are names of javascript callables. Each callable must return either true/false or an object where object.result = (true or false) and object.message = (return message). Validation fails if any callable returns false in the result.
  • autocomplete - The url of the datasource (returning data delimited by newlines). Default: None
  • autocomplete_options - A dictionary of autocomplete options to be passed directly to the autocompleter

Note: All HTML 4.0 attributes are supported as keyword arguments and are directly passed to the input tag. The list of supported attributes are given in input_attributes

grid_tag(c, id, **kwargs)
Class Method

 

Create a grid

Using Grids

To use a grid which stores data on the server, a server side control must first be initialized.

>>> grid_id = iris.root.set_control_data(grid_data, id="my_grid")

The id is optional and autogenerated if not specified.

In your template file, create a grid tag as follows (The example uses Cheetah Templating syntax):

$widgets.grid_tag($grid_id, width="800px", columns=["Name", "Place", "Animal", "Thing"], toolbar=False) This will generate a div and associated script tag which will render a 4-column grid which is 800px wide and does not have a toolbar.

Parameters:
  • id - The id of the grid as returned by iris.root.set_control_data
  • url - A url of the custom json data source to use. Default: The url is generated from the id.
  • data - A list of dictionaries to be used as the data for the grid. Default: The data is loaded from the url.
  • datalength - If this is provided, then the datasource downloads the data in optimized chunks.
  • width - A css value for width. Default: auto
  • columns - A list of column names or dictionaries. Default: Automatically calculated
  • groupby - An ordered list of column names to group by. Default: [] (no grouping)
  • filterable - Boolean value denoting whether or not the rows can by filtered by column value. Default: True. Disable this to improve performance.
  • sortable - Boolean value denoting whether or not the rows can by sorted. Default: True. Disable this to improve performance.
  • pagesize - The number of items to show per page. Default: 25. If pagesize is negative or None, the table is not paginated.
  • printable - Boolean value denoting whether or not the "Print" button should be shown on the toolbar. Default: True.
  • excel - Boolean value denoting whether or not the "Export to Excel" button should be shown on the toolbar. Default: True. This option is not available if the data keyword argument is provided.
  • toolbar - Boolean value denoting whether or not the toolbar should be shown. If the toolbar is hidden, all buttons on it are also hidden and hence inaccessible. Default: True.
Notes:
  • If an entry in columns is a dictionary, it must contain a key "name" whose value is the key of the corresponding column in the data list This dictionary may optionally contain the following additional keys
    • name: The column name. Required.
    • display/text/html: The html text to display as the column name instead of 'name'
    • width: A CSS value for the width of the column.
    • menu: Boolean value denoting whether or not to display the context sensitive menu. Default: True
    • sortable: Boolean value denoting whether or not to enable sorting. Default: True.
    • sortorder: "asc" for Ascending, "desc" for Descending. Default: Unsorted.
    • visible: Boolean value denoting whether or not to display the column. Default: True
    • filterable: Boolean value denoting whether or not the column is filterable. Default: True. Disable this to improve performance.
    • filterby: Value of column to filter on. Default: Unfiltered
    • barchart: Boolean value denoting whether or not to display bar charts. Default: False
    • colorchart: Boolean value denoting whether or not to display color charts. Default: False.
  • Data chunking tries to modify chunksize so that the number of requests stays between 1 and 5. It starts with 200 items per chunk and uses a multiplier of 10. FF2.0, IE7 all use up to 2 parallel requests per hostname for HTTP1.1 and 4 parallel requests for HTTP1.0. IE8 does 6 parallel requests. 5 maximum requests should be a good balance between request overhead and download time to first response.

chart_tag(c, id, ch_type, width, height, columns, **kwargs)
Class Method

 

Render a chart using an IFRAME

Parameters:
  • id - The id of the chart data as returned by iris.root.set_control_data
  • ch_type - A charting constant as defined in the widgets module.
  • width (int) - Width of the chart in pixels.
  • height (int) - Height of the chart in pixels.
  • columns - A list of column names to be used as the series.
  • url - A url of the custom json data source to use. Default: The url is generated from the id.
  • data - A list of data values for the chart. Default. The data is loaded from the URL.

Note: If an entry in columns is a dictionary, it must contain a key "name" whose value is the key of the corresponding column in the data list This dictionary may optionally contain the following additional keys

  • name: The column name. Required.
  • display/text/html: The html text to display as the column name instead of 'name'


Class Variable Details

input_attributes

Value:
'type', 'name', 'value', 'size', 'maxlength', 'checked', 'src', 'class\
', 'id', 'dir', 'lang', 'title', 'style', 'align', 'alt', 'accept', 'r\
eadonly', 'disabled', 'tabindex', 'accesskey', 'ismap', 'usemap', 'onf\
ocus', 'onblur', 'onselect', 'onchange', 'onclick', 'ondbclick', 'onmo\
usedown', 'onmouseup', 'onmouseover', 'onmousemove', 'onmouseout', 'on\
keypress', 'onkeydown', 'onkeyup'

grid_keys

Value:
'pagesize', 'columns', 'groupby', 'filterable', 'sortable', 'width', '\
toolbar'

notification_keys

Value:
'delay', 'duration', 'width', 'height', 'image'