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', style=None, 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>.
-
head
= None
The Head HTMLElement of this page
-
body
= None
The Body HTMLElement of this page
TwoColumnPage
-
class
reahl.web.ui.
TwoColumnPage
(view, title='$current_title', style=None, css_id=None)
- An HTML5Page with a basic layout: It has a header area which displays at top of two columns. A footer area
displays below the two columns. The main column is to the right, and larger. The secondary column is to
the left, and smaller.
Styling
- Renders as a page structured using Yui 2, with two template preset columns
- (main and secondary).
The TwoColumnPage has the following Slots:
- main
- Used by Views to plug content into the main column.
- secondary
- Used by Views to plug content into the secondary column.
- header
- Used by Views to plug content into the header area.
- footer
- Used by Views to plug content into the footer area.
Deprecated since version 3.1: Please use reahl.web.layout:PageLayout instead.
-
footer
The Div used as footer area.
-
header
The Div used as header area.
-
main
The Div used as main column.
-
secondary
The Div used as secondary column.
-
factory
(*widget_args, **widget_kwargs)
Obtains a Factory for this Widget. A Factory for this Widget is merely an object that will be used by the
framework to instantiate the Widget only once needed. Pass the exact arguments and keyword arguments
that you would have passed to the Widget’s constructor, except the very first argument of Widgets: the view.
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>
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 )
|
-
classmethod
from_columns
(view, columns, items, caption_text=None, summary=None, css_id=None)
Creates a table populated with rows, columns, header and footer, with one row per provided item. The table is
defined by the list of DynamicColumn
or StaticColumn
instances passed in.
-
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.
Tabbed or sliding panels
Tab
-
class
reahl.web.ui.
Tab
(view, title, tab_key, contents_factory, css_id=None)
One Tab in a TabbedPanel
.
Styling
Rendered like a MenuItem
, with the <a> containing title.
Parameters: |
- view – (See
reahl.web.fw.Widget )
- title – Text that is displayed inside the Tab itself.
- tab_key – A name for this tag identifying it uniquely amongst other Tabs in the same
TabbedPanel .
- contents_factory – A
WidgetFactory specifying how to create the contents of this Tab, once selected.
- css_id – (Deprecated)
|
MultiTab
-
class
reahl.web.ui.
MultiTab
(view, title, tab_key, contents_factory, css_id=None)
A composite tab. Instead of a single choice for the user, clicking on a MultiTab
results in a dropdown menu with more choices for the user.
Styling
Rendered like a Tab
, but with more contents. The usual <a> containing the title
is followed by an and an <a class=”dropdown-handle”>. This is followed by a
normal VMenu
.
TabbedPanel
-
class
reahl.web.ui.
TabbedPanel
(view, css_id)
A Div sporting different Tabs which the user can select to change what is displayed. The contents
of a TabbedPanel are changed when the user clicks on a different Tab without refreshing the entire
page, provided that JavaScript is available on the user agent.
Styling
Rendered as a <div class=”reahl-tabbedpanel”> which contains two children: an HMenu
containing instances of Tab
for MenuItems, followed by a <div> that will be populated
by the current contents of the TabbedPanel.
-
add_tab
(tab)
Adds the Tab tab to this TabbedPanel.
SlidingPanel
-
class
reahl.web.ui.
SlidingPanel
(view, css_id=None, next='>', prev='<')
A Div which contains a number of other Panels, only one of which is displayed at a time.
It sports controls that can be clicked by a user to advance the displayed content to the
next or previous Div. Advancing is done by visually sliding in the direction indicated
by the user if JavaScript is available. The panels advance once every 10 seconds if no
user action is detected.
Styling
Rendered as a <div class=”reahl-slidingpanel”> which contains three children: a <div class=”viewport”>
flanked on either side by an <a> (the controls for forcing it to transition left or right). The
labels passed as next and prev are embedded in <span> tags inside the <a> tags.
The Div
instances added to the SlidingPanel
are marked with a class="contained"
.
For a SlidingPanel to function property, you need to specify a height and width to
div.reahl-slidingpanel div.viewport
.
-
add_panel
(panel)
Adds panel to the list of Div
instances that share the same visual space.
Support for Yui 2 CSS Grids
YuiDoc
-
class
reahl.web.ui.
YuiDoc
(view, doc_id, doc_class, css_id=None)
A Yui 2 #doc div: the container of the #hd, #bd and #ft (see http://developer.yahoo.com/yui/grids/#start)
Deprecated since version 3.1: Please use reahl.web.layout:PageLayout instead.
-
hd
= None
-
bd
= None
-
secondary_block
= None
the secondary div (see Yui 2 template presents)
-
main_block
= None
the #yui-main div (see Yui 2 template presents)
-
ft
= None
-
factory
(*widget_args, **widget_kwargs)
Obtains a Factory for this Widget. A Factory for this Widget is merely an object that will be used by the
framework to instantiate the Widget only once needed. Pass the exact arguments and keyword arguments
that you would have passed to the Widget’s constructor, except the very first argument of Widgets: the view.
YuiUnit
-
class
reahl.web.ui.
YuiUnit
(view, first=False)
A Yui 2 unit: see http://developer.yahoo.com/yui/grids/#start
Deprecated since version 3.1: Please use reahl.web.pure:ColumnLayout instead.
-
factory
(*widget_args, **widget_kwargs)
Obtains a Factory for this Widget. A Factory for this Widget is merely an object that will be used by the
framework to instantiate the Widget only once needed. Pass the exact arguments and keyword arguments
that you would have passed to the Widget’s constructor, except the very first argument of Widgets: the view.
YuiGrid
-
class
reahl.web.ui.
YuiGrid
(view, css_id=None)
A Yui 2 grid: see http://developer.yahoo.com/yui/grids/#start
Deprecated since version 3.1: Please use reahl.web.pure:ColumnLayout instead.
-
factory
(*widget_args, **widget_kwargs)
Obtains a Factory for this Widget. A Factory for this Widget is merely an object that will be used by the
framework to instantiate the Widget only once needed. Pass the exact arguments and keyword arguments
that you would have passed to the Widget’s constructor, except the very first argument of Widgets: the view.
YuiBlock
-
class
reahl.web.ui.
YuiBlock
(view, css_id=None)
A Yui 2 block: see http://developer.yahoo.com/yui/grids/#start
Deprecated since version 3.1: Please use reahl.web.pure:ColumnLayout instead.
-
factory
(*widget_args, **widget_kwargs)
Obtains a Factory for this Widget. A Factory for this Widget is merely an object that will be used by the
framework to instantiate the Widget only once needed. Pass the exact arguments and keyword arguments
that you would have passed to the Widget’s constructor, except the very first argument of Widgets: the view.
Misc
Panel
-
class
reahl.web.ui.
Panel
(view, css_id=None)
A logical container for other Widgets.
Styling
Renders as an HTML <div> element.
Deprecated since version 3.2: Please use reahl.web.ui:Div instead
-
factory
(*widget_args, **widget_kwargs)
Obtains a Factory for this Widget. A Factory for this Widget is merely an object that will be used by the
framework to instantiate the Widget only once needed. Pass the exact arguments and keyword arguments
that you would have passed to the Widget’s constructor, except the very first argument of Widgets: the view.
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.
|
PriorityGroup
-
class
reahl.web.ui.
PriorityGroup
A PriorityGroup ensures that only one of the Widgets added to it has primary priority,
the others in the group can have secondary priority, or no priority specified. This
is used for styling Widgets based on their priority in the PriorityGroup.
-
add
(widget)
Adds widget, with no priority set.
-
add_secondary
(widget)
Adds widget, with secondary priority.
-
add_primary
(widget)
Adds widget, with primary priority.
ErrorFeedbackMessage
-
class
reahl.web.ui.
ErrorFeedbackMessage
(view, text=None, css_id=None, html_escape=True)
A user message indicating some error condition, such as a form validation which failed.
Styling
Renders as an HTML <p class=”error feedback”> element.