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)
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>.
Changed in version 4.0: Removed style= keyword
-
head
= None
The Head HTMLElement of this page
-
body
= None
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)
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.
RunningOnBadge
-
class
reahl.web.ui.
RunningOnBadge
(view)
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>
LiteralHTML
-
class
reahl.web.ui.
LiteralHTML
(view, contents, transform=<function LiteralHTML.<lambda>>)
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)
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)
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.
|
DynamicColumn
-
class
reahl.web.ui.
DynamicColumn
(make_heading_or_string, make_widget, sort_key=None)
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.
- sort_key – If specified, this value will be passed to sort() for sortable tables.
|
StaticColumn
-
class
reahl.web.ui.
StaticColumn
(field, attribute_name, sort_key=None)
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.
- sort_key – If specified, this value will be passed to sort() for sortable tables.
|
Caption
-
class
reahl.web.ui.
Caption
(view, text=None, css_id=None)
An HTML caption element.
Styling
Renders as an HTML <caption> element.
Thead
-
class
reahl.web.ui.
Thead
(view, css_id=None)
An HTML thead element. Contains the header of the table columns.
Tbody
-
class
reahl.web.ui.
Tbody
(view, css_id=None)
An HTML tbody element. Contains the rows with data in the table.
Tr
-
class
reahl.web.ui.
Tr
(view, css_id=None)
An HTML tr element represents one row of data in a table.
Td
-
class
reahl.web.ui.
Td
(view, rowspan=None, colspan=None, css_id=None)
An HTML td element - a single cell of data inside a row of a table.
Th
-
class
reahl.web.ui.
Th
(view, rowspan=None, colspan=None, css_id=None)
An HTML th element - a single cell heading for a column of a table.