. Copyright 2013-2016 Reahl Software Services (Pty) Ltd. All rights reserved.
Module reahl.web.ui
Basic Widgets and related user interface elements.
Widgets for constructing a page
HTML5Page
-
class reahl.web.ui.HTML5Page(view, title='$current_title', css_id=None)
Bases: HTMLElement
A web page that may be used as the page of a web application. It ensures that everything needed by
the framework (linked CSS and JavaScript, etc) is available on such a page.
Styling
Renders as an HTML5 page with customised <head> and an empty <body>.
- Parameters:
-
Changed in version 4.0: Removed style= keyword
-
head
The Head HTMLElement of this page
-
body
The Body HTMLElement of this page
-
render()
Returns an HTML representation of this Widget. (Not for general use, may be useful for testing.)
Slot
-
class reahl.web.ui.Slot(view, name)
Bases: Widget
A Slot is a placeholder area on a page into which different Views can plug different Widgets on the fly.
Using Slots, one can create a single HTML5page which can be
re-used by different Views instead of having to create
similar-looking HTML5Pages for each View in an application.
A Slot is added to an HTML5Page to represent an area that will be
populated later by a View. When a View is served up the framework
can then populate this empty area with Widgets specific to the
current View.
- Parameters:
-
RunningOnBadge
-
class reahl.web.ui.RunningOnBadge(view)
Bases: A
A visual badge proclaiming that a website is “Running on Reahl”. Using it on your site
is a bit of advertising for Reahl!
Styling
Renders as an HTML <a class=”runningon”> containing an <img>
- Parameters:
view – (See reahl.web.fw.Widget
)
LiteralHTML
-
class reahl.web.ui.LiteralHTML(view, contents, transform=<function LiteralHTML.<lambda>>)
Bases: Widget
The LiteralHTML Widget renders a chunk of HTML as given in
contents. If a single-argument callable is given as transform,
contents will first be passed to that callable to possibly
change the HTML on-the-fly before rendering (the callable should
return the changed HTML to be rendered).
- Parameters:
view – (See reahl.web.fw.Widget
)
contents – Some literal HTML.
transform – If given, it is called passing contents to possibly transform contents before rendering.
The callable should return the final HTML to be rendered.
-
render()
Returns an HTML representation of this Widget. (Not for general use, may be useful for testing.)
Tables
Table
-
class reahl.web.ui.Table(view, caption_text=None, summary=None, css_id=None)
Bases: HTMLElement
An HTML table element: data displayed on columns and rows.
- Parameters:
view – (See reahl.web.fw.Widget
)
caption_text – If text is given here, a caption will be added to the table containing the caption text.
summary – A textual summary of the contents of the table which is not displayed visually, but may be used by a user agent for accessibility purposes.
css_id – (See reahl.web.ui.HTMLElement
)
-
with_data(columns, items, footer_items=None)
Populate the table with the given data. Data is arranged into columns as
defined by the list of DynamicColumn
or StaticColumn
instances passed in.
- Parameters:
columns – The DynamicColumn
instances that define the contents of the table.
items – A list containing objects represented in each row of the table.
footer_items – If given a footer is added. A list containing objects represented in each footer row of the table.
Changed in version 5.0: Added footer_items.
DynamicColumn
-
class reahl.web.ui.DynamicColumn(make_heading_or_string, make_widget, make_footer_widget=None, sort_key=None)
Bases: object
DynamicColumn defines a logical column of a table, specifying how its heading will be
rendered, and how the cell in this column will be displayed for each data item in the
table.
- Parameters:
make_heading_or_string – A string to be used as heading for this column, or a single-argument callable that will be called (passing the current view) in order to compute a Widget to be displayed as heading of the column.
make_widget – A callable that takes two arguments: the current view, and an item of data of the current table row. It will be called to compute a Widget to be displayed in the current column for the given data item.
make_footer_widget – A callable that takes two arguments: the current view, and an item representing a row of footer data. It will be called to compute a Widget to be displayed in the footer column representing the footer item. :keyword sort_key: If specified, this value will be passed to sort() for sortable tables.
Changed in version 5.0: Added make_footer_widget.
StaticColumn
-
class reahl.web.ui.StaticColumn(field, attribute_name, footer_label=None, sort_key=None)
Bases: DynamicColumn
StaticColumn defines a column whose heading and contents are derived from the given field.
- Parameters:
field – The Field
that defines the heading for this column, and which will also be used to get the data to be displayed for each row in this column.
attribute_name – The name of the attribute to which field should be bound to on each data item when rendering this column.
footer_label – If specified, this text will be put in a footer row for each footer item in this column.
sort_key – If specified, this value will be passed to sort() for sortable tables.
Changed in version 5.0: Added footer_label.
Caption
-
class reahl.web.ui.Caption(view, text=None, css_id=None)
Bases: HTMLElement
An HTML caption element.
Styling
Renders as an HTML <caption> element.
- Parameters:
-
Thead
-
class reahl.web.ui.Thead(view, css_id=None)
Bases: HTMLElement
An HTML thead element. Contains the header of the table columns.
- Parameters:
-
Tbody
-
class reahl.web.ui.Tbody(view, css_id=None)
Bases: HTMLElement
An HTML tbody element. Contains the rows with data in the table.
- Parameters:
-
Tr
-
class reahl.web.ui.Tr(view, css_id=None)
Bases: HTMLElement
An HTML tr element represents one row of data in a table.
- Parameters:
-
Td
-
class reahl.web.ui.Td(view, rowspan=None, colspan=None, css_id=None)
Bases: Cell
An HTML td element - a single cell of data inside a row of a table.
- Parameters:
-
Th
-
class reahl.web.ui.Th(view, rowspan=None, colspan=None, css_id=None)
Bases: Cell
An HTML th element - a single cell heading for a column of a table.
- Parameters:
-