page¶
- class virtualitics_sdk.page.page.Page(title, sections)¶
Bases:
ABC
The Page for a Step.
- Parameters:
title (
str
) – The title of the Page.sections (
List
[Section
]) – The sections contained inside the Page.
EXAMPLE:
# Imports from virtualitics_sdk.page.page import Page from virtualitics_sdk.page.section import Section . . . # Example usage class ExStep(Step): def run(self, flow_metadata): . . . ex_step_page = Page(title="Example Page", sections=[Section("", [])]) ex_step = ExStep(title="Example", description="", parent="Data & Visualizations", type=StepType.RESULTS, page=ex_step_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 (
str
) – The subtitle for the new card to be added, defaults to “”.card_description (
str
) – The description for the new card to be added, defaults to “”.card_id (
str
) – The ID of the new card to be added, defaults to “”.show_card_title (
bool
) – whether to show the title of the card on the page when rendered, defaults to True.show_card_description (
bool
) – whether 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.
- property elements: Iterator[Element]¶
- 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 ID.
- 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_id(elem_id)¶
Returns the Element on a Page with a specified ID.
- Parameters:
elem_id (
str
) – The title of the element.- Raises:
ValueError – if no element exists with the specified title.
- Return type:
Element
- 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:
Element
- 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:
- 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)¶
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 (
str
) – The subtitle of the card, defaults to “”card_description (
str
) – The description of the card, defaults to “”show_card_title (
bool
) – whether to show the title of the card on the page when rendered, defaults to Trueshow_card_description (
bool
) – whether 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.
- property sections: List[Section]¶
Return the sections of a Page.
- Returns:
The sections on a given Page.
- update_card_title(new_card_title, card_title=None, card_id=None)¶
Update the title of card using the card_title or the card_id
- Parameters:
new_card_title (
str
) – The new title of the card.card_title (
Optional
[str
]) – The title of the card, defaults to None.card_id (
Optional
[str
]) – The ID of the card, defaults to None.
- Raises:
PredictException – If card_title or card_id are not specified.
CardNotFoundException – if no card exists with the specified title or ID.