Engel Widgets¶
Abstract Widgets¶
Note
All widgets in this package are not meant to be used directly. They are mostly used by the framework, or subclassed into usable widgets.
-
class
engel.widgets.abstract.HeadLink(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseElementWidget representing links described in the
<head>section of a typical HTML document. This widget is used by the framework to generate links to stylesheets and auto-generated javascript files.-
build(link_type, path)¶
-
html_tag= 'link'¶
-
link_type¶ Link type (Ex: stylesheet)
-
target¶ File to which the HeadLink is pointing
-
-
class
engel.widgets.abstract.PageTitle(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseElementWidget representing the title of the page. This widget is used by
render().-
build(text)¶
-
html_tag= 'title'¶
-
-
class
engel.widgets.abstract.Script(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseElementWidget representing a script element.
-
build(js_path)¶
-
html_tag= 'script'¶
-
source¶ Location of the script
-
Base Widgets¶
-
class
engel.widgets.base.BaseContainer(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseElementBase class common to all widgets that can contain other widgets.
-
__init__(id, classname=None, parent=None, **kwargs)¶ Constructor of the Base Container
-
add_child(child)¶ Add a new child element to this widget.
Parameters: child – Object inheriting BaseElement.
-
clear_children()¶ Remove the children of this widget
-
compile()¶ Recursively compile this widget as well as all of its children to HTML.
Returns: HTML string representation of this widget.
-
parent¶
-
remove_child(child)¶ Remove a child widget from this widget.
Parameters: child – Object inheriting BaseElement
-
replace_child(old_child, new_child)¶
-
-
class
engel.widgets.base.BaseElement(id, classname=None, parent=None, **kwargs)¶ Bases:
objectBase class common to all Engel widgets.
-
__init__(id, classname=None, parent=None, **kwargs)¶ Constructor of the base widget.
Parameters: - id – ID of the widget
- classname – Class name of the widget Analogous to HTML classes, mostly used for styling. (
string) - parent – Parent widget (Subclass of
BaseElement)
-
add_class(classname)¶
-
build(**kwargs)¶ Gets called before the widget gets attached to a view. Override this to define your widget’s specific traits.
-
classname¶
-
compile()¶ Generate the HTML representing this widget.
Returns: HTML string representing this widget.
-
html_tag= None¶ HTML tag of this widget.
-
id¶
-
on_view_attached()¶ Gets called when the widget gets attached to a view.
-
parent¶
-
remove_class(classname)¶
-
view¶
-
Form-related Widgets¶
-
class
engel.widgets.forms.Button(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseElementA simple button.
-
build(text)¶
-
html_tag= 'button'¶
-
-
class
engel.widgets.forms.TextBox(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseElementA simple textbox.
-
build(name=None)¶
-
html_tag= 'input'¶
-
input_type¶ Type of the
<input>tag. (defaults to “text”)
-
name¶ Name of the data bound to the textbox. (Optional, used with forms.)
-
on_view_attached()¶
-
text¶ Text content of the TextBox
-
Media Widgets¶
-
class
engel.widgets.media.Audio(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseElementA simple audio widget.
-
build(audio_path)¶
-
html_tag= 'audio'¶
-
source¶ Path of the audio file
-
-
class
engel.widgets.media.Image(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseElementA simple image widget.
-
build(img_url)¶
-
html_tag= 'img'¶
-
source¶ Path of the image file
-
-
class
engel.widgets.media.ImageLink(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseContainerAn image widget, with the added feature of linking to an external URL.
-
build(link, img_url)¶
-
html_tag= 'a'¶
-
target¶ Target of the link
-
-
class
engel.widgets.media.Video(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseElementA simple video widget, set via
Video.loopto loop by default.-
build(vid_url)¶
-
html_tag= 'video'¶
-
loop¶ Loop the video? (“true” / “false”) (defaults to
"true")
-
source¶ Path of the video file
-
Structural Widgets¶
-
class
engel.widgets.structure.Body(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseContainerSimple container analogous to the html
<body>element.-
html_tag= 'body'¶
-
-
class
engel.widgets.structure.Document(id, view, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseContainerA document. Analogous to the HTML
<html>element.-
__init__(id, view, classname=None, parent=None, **kwargs)¶ Parameters: view – Viewin which the document is declared.
-
html_tag= 'html'¶
-
-
class
engel.widgets.structure.Head(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseContainer-
html_tag= 'head'¶
-
load_script(path)¶ Proper way to dynamically inject a script in a page.
Parameters: path – Path of the script to inject.
-
load_stylesheet(id, path)¶ Proper way to dynamically inject a stylesheet in a page.
Parameters: path – Path of the stylesheet to inject.
-
-
class
engel.widgets.structure.List(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseContainerBridges python and HTML lists.
Listexposes an interface similar to python lists and takes care of updating the corresponding HTML<ul>when the python object is updated.-
__init__(id, classname=None, parent=None, **kwargs)¶
-
add_child(widget)¶ Append a widget to the list.
Parameters: widget – Object inheriting BaseElement
-
html_tag= 'ul'¶
-
remove_child(widget)¶ Remove a widget from the list.
Parameters: widget – Object inheriting BaseElement
-
-
class
engel.widgets.structure.Panel(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseContainerSimple container analogous to the html
<div>element.-
html_tag= 'div'¶
-
Text Widgets¶
-
class
engel.widgets.text.Paragraph(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseElementSimple paragraph widget
-
build(text)¶ Parameters: text – Content of the paragraph
-
html_tag= 'p'¶
-
-
class
engel.widgets.text.Span(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseElementSimple span widget
-
build(text)¶ Parameters: text – Content of the span
-
html_tag= 'span'¶
-
-
class
engel.widgets.text.TextLink(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseElementText widget linking to an external URL.
-
build(text, url)¶ Parameters: - text – Text of the link
- url – Target URL
-
html_tag= 'a'¶
-
target¶ Target of the link
-
-
class
engel.widgets.text.Title(id, classname=None, parent=None, **kwargs)¶ Bases:
engel.widgets.base.BaseElementTitle widget analogous to the HTML <h{n}> elements.
-
build(text, size=1)¶ Parameters: - text – Text of the widget
- size – Size of the text (Higher size = smaller title)
-