Skip to content

Page class

Generic page generator.

The Page class transforms template text into actual pages that can be displayed on a web browser.

When a page is requested to be displayed, it is converted into HTML code that can be sent to the client. All control placeholders are replaced by their respective graphical component so you can show your application variables and interact with them.

Methods

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_content()

set_content(content: str) -> None

Set a new page content.

Reads the new page content and re-initializes the Page instance to reflect the change.

Important

This function can only be used in an IPython notebook context.

Parameters:

Name Type Description Default

content

str

The text content or the path to the file holding the text to be transformed. If content is a path to a readable file, the file is read entirely as the text template.

required

Raises:

Type Description
RuntimeError

If this method is called outside an IPython notebook context.

set_style()

set_style(style: t.Dict[str, t.Dict[str, t.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",
    }
  }
}
That would set the "css_property1" to "css_value1" for all elements with the "class1" class, and "css_property2" to "css_value2" for all elements with the "class3" class that are descendants of elements with the "class2" class.

Parameters:

Name Type Description Default

style

dict

A dictionary describing the style as CSS or Nested CSS.

required

Returns:

Type Description
Page

This Page instance.