page#
- class predict_backend.page.page.Page(title, type, metadata, sections)#
Bases:
ABC
The Page for a Step.
- Parameters:
title (
str
) – The title of the Page.type (
PageType
) – The page type (soon to be deprecated).metadata (
dict
) – The metadata for the page.sections (
List
[Section
]) – The sections contained inside the Page.
- add_card_to_section(card, section_title)#
Adds a Card to a specified section.
- Parameters:
card (
Card
) – The Card to add.section_title (
str
) – The title of the section the Card will be added to.
- Raises:
ValueError – if no section with that title is found on the page.
- add_content_to_section(elems, section_title, card_title='', card_subtitle='', card_description='', card_id='', show_card_title=True, show_card_description=True, page_update=None)#
Adds content to a section. This adds the specified elements into a single Card on a Section.
- Parameters:
elems (
Union
[Element
,List
[Element
],List
[Row
]]) – The elements to add to the new Card in this Section.section_title (
str
) – The title of the section to add elements to.card_title (
str
) – The card title for the new card to be added, defaults to “”.card_subtitle – The subtitle for the new card to be added, defaults to “”.
card_description – The description for the new card to be added, defaults to “”.
card_id – The ID of the new card to be added, defaults to “”.
show_card_title (
bool
) – Whether or not to show the title of the card on the page when rendered, defaults to True.show_card_description (
bool
) – Whether or not to show the description of the card to the page when rendered, defaults to True.page_update (
Optional
[Callable
]) – The page update function for the new card, defaults to None.
- Raises:
ValueError – if the section title is not found on the Page.
- get_card_by_id(card_id)#
Returns the Card on a Page with a specified ID.
- Parameters:
card_id (
str
) – The ID of the card.- Raises:
CardNotFoundException – if no card exists with the specified title.
- Return type:
- get_card_by_title(card_title, quiet=False)#
Returns the Element on a Page with a specified ID.
- Parameters:
card_title (
str
) – The title of the card.quiet (
bool
) – If True, return None if Card is not found. Defaults to False
- Raises:
CardNotFoundException – if no card exists with the specified title and quiet is False.
- Return type:
- get_element_by_title(elem_title, quiet=False)#
Returns the first Element on a Page with a specified title.
- Parameters:
elem_title (
str
) – The title of the section to retrieve.quiet (
bool
) – If True, return None if element is not found. Defaults to False
- Raises:
ValueError – if no element exists with the specified title.
- Return type:
- get_section_by_title(section_title)#
Returns the first Section on a Page with a specified title.
- Parameters:
section_title (
str
) – The title of the section to retrieve.- Raises:
ValueError – if no section exists with the specified title.
- Return type:
- property has_required_input: bool#
- remove_card(section_title, card_title)#
Remove a card from a Page. This can be called inside dynamic pages to restructure a Page. If no card exists with that title, the page will not be changed and this function will not error.
- Parameters:
section_title (
str
) – The section on the page where the Card should be removedcard_title (
str
) – The title of the Card to be removed
- Raises:
ValueError – If the section title does not exist on the pageQ
- replace_content_in_section(elems, section_title, card_title, card_subtitle='', card_description='', show_card_title=True, show_card_description=True, page_update=None, filter_update=None, as_columns=False)#
Replaces the content on a card with new content. If that card doesn’t exist, it will add the card to the section. It’s highly recommended to use this function inside of page updates because no matter how many times the page is updated, only one card will be shown.
- Parameters:
elems (
Union
[Element
,List
[Element
],List
[Row
]]) – The elements to replace the card withsection_title (
str
) – The title of the section the new card should exist incard_title (
str
) – The title of the cardcard_subtitle – The subtitle of the card, defaults to “”
card_description – The description of the card, defaults to “”
show_card_title (
bool
) – Whether or not to show the title of the card on the page when rendered, defaults to Trueshow_card_description (
bool
) – Whether or not to show the description of the card to the page when rendered, defaults to Truepage_update (
Optional
[Callable
]) – The page update function for the new card, defaults to None.filter_update (
Optional
[Callable
]) – The filter update function for the new card, defaults to None.as_columns – Whether or not to add content in columns instead of rows, defaults to False.
- serialize()#