Coverage for src/ipyvizzustory/env/pn/story.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.5.4, created at 2024-07-10 10:22 +0000

1"""A module for working with presentation stories in `Panel` environment.""" 

2 

3from typing import Optional 

4 

5from panel.pane import HTML 

6 

7from ipyvizzu import Data, Style 

8 

9from ipyvizzustory.storylib.story import Story as StoryLib 

10 

11 

12class Story(StoryLib): 

13 """A class for representing a presentation story in `Panel` environment.""" 

14 

15 def __init__(self, data: Data, style: Optional[Style] = None): 

16 """ 

17 Presentation Story constructor. 

18 

19 Args: 

20 data: Data set for the whole presentation story. 

21 After initialization `data` can not be modified, 

22 but it can be filtered. 

23 style: Style settings for the presentation story. 

24 `style` can be changed at each presentation step. 

25 """ 

26 

27 super().__init__(data=data, style=style) 

28 

29 def play(self) -> None: 

30 """A method for displaying the assembled `HTML` code in `Panel` environment.""" 

31 

32 _width, _height = self._size.get_width_height_in_pixels() 

33 

34 HTML( 

35 self.to_html(), 

36 width=_width, 

37 height=_height, 

38 ).servable()