Page class
Page generator for the Builder API.
This class is used to create a page created with the Builder API.
Instances of this class can be added to the application using Gui.add_page()
.
This class is typically be used as a Python Context Manager to add the elements.
Here is how you can create a single-page application, creating the elements with code:
from taipy.gui import Gui
from taipy.gui.builder import Page, button
def do_something(state):
pass
if __name__ == "__main__":
with Page() as page:
button(label="Press me", on_action=do_something)
Gui(page).run()
Methods¶
__init__() ¶
__init__(
element: Optional[_Element] = None, **kwargs
) -> None
Initialize a new page.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
*Element*
|
An optional element, defined in the |
None
|
The Page
constructor supports the style parameter as explained in the
section on Styling and in the
set_style()
method.
create_page() ¶
create_page() -> t.Optional[Page]
Create the page content for page modules.
If this page is a page module, this method must be overloaded and return the page content.
This method should never be called directly: only the Taipy GUI internals will.
The default implementation returns None, indicating that this class does not implement a page module.
Returns:
Type | Description |
---|---|
Optional[Page]
|
The page content for this Page subclass, making it a page module. |
set_style() ¶
set_style(style: Dict[str, Dict[str, Any]]) -> Page
Set the style for this page.
The style parameter must contain a series of CSS rules that apply to the generated
page.
Each key of this dictionary should be a CSS selector and its associated value must be
a CSS declaration or a CSS rule itself, benefiting from
nested CSS
features.
For example, you could set the style parameter to:
{
"class1": {
"css_property1": "css_value1",
}
"class2": {
"class3": {
"css_property2": "css_value2",
}
}
}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
dict
|
A dictionary describing the style as CSS or Nested CSS. |
required |
Returns:
Type | Description |
---|---|
Page
|
This |