Compose complex screens by adding simple Widgets together.
panel1 = Div(view) panel1.add_child(P(view, text='a paragraph with text'))
a paragraph with text
Complex Widgets have rich client-side and server side behaviour.
sliding_panel = SlidingPanel(view) panel1 = sliding_panel.add_panel(Div(view)) panel1.add_child(P(view, text='a paragraph with text')) panel2 = sliding_panel.add_panel(Div(view)) panel2.add_child(P(view, text='a different paragraph'))
Entire pages are Widgets too, also composed of other Widgets...
class MyPage(HTML5Page): def __init__(self, view): super(MyPage, self).__init__(view) paragraph = P(view, text='Hello, I am a paragraph') self.body.add_child(paragraph)
Sometimes Widget creation is delayed using a Factory that will create the Widget only once necessary.
tabbed_panel = TabbedPanel(view, 'mytabbedpanel') tab1 = Tab(view, 'Tab 1', '1', P.factory(text='Some text.')) tabbed_panel.add_tab(tab1) tab2 = Tab(view, 'Tab 2', '2', P.factory(text='More text.')) tabbed_panel.add_tab(tab2)
A web application consists of a UserInterface, on which URLs are mapped to Views.
class TabbedPanelUI(UserInterface): def assemble(self): self.define_view('/', title='Demo', page=MyPage.factory())