|
12 | 12 | """
|
13 | 13 |
|
14 | 14 | # import displayio
|
15 |
| -from . import ProgressBarBase # , FillDirection |
| 15 | +from . import ProgressBarBase, FillDirection |
16 | 16 |
|
17 | 17 |
|
18 | 18 | class HorizontalProgressBar(ProgressBarBase):
|
19 |
| - """ |
20 |
| - A progress bar that goes horizontally. |
| 19 | + """A dynamic progress bar widget. |
| 20 | +
|
| 21 | + The anchor position is the position where the control would start if it |
| 22 | + were being read visually or on paper, where the (0, 0) position is |
| 23 | + the lower-left corner for ascending progress bars (fills from the bottom to |
| 24 | + to the top in vertical bars, or from the left to the right in horizontal |
| 25 | + progress bars), upper-left corner for descending progress bars (fills from |
| 26 | + the top to the bottom). |
| 27 | +
|
| 28 | + Using the diagrams below, the bar will fill in the following directions:: |
| 29 | +
|
| 30 | + ----------------------------- |
| 31 | + | Horizontal | Vertical | |
| 32 | + ---------------------------------------------- |
| 33 | + | Ascending | 1-3 to 2-4 | 3-4 to 1-2 | |
| 34 | + ---------------------------------------------- |
| 35 | + | Descending | 2-4 to 1-3 | 1-2 to 3-4 | |
| 36 | + ---------------------------------------------- |
| 37 | +
|
| 38 | + Vertical Horizontal |
| 39 | +
|
| 40 | + 1--2 1-----------------------2 |
| 41 | + | | | | |
| 42 | + | | | | |
| 43 | + | | 3-----------------------4 |
| 44 | + | | |
| 45 | + 3--4 |
| 46 | +
|
| 47 | + :param anchor_position: The anchor coordinates of the progress bar. |
| 48 | + :type anchor_position: Tuple[int, int] |
| 49 | + :param size: The size in (width, height) of the progress bar |
| 50 | + :type size: Tuple[int, int] |
| 51 | + :param progress: The percentage of the progress bar. |
| 52 | + :type progress: float |
| 53 | + :param bar_color: The color of the progress bar. Can be a hex |
| 54 | + value for color. |
| 55 | + :param outline_color: The outline of the progress bar. Can be a hex |
| 56 | + value for color. |
| 57 | + :type outline_color: int |
| 58 | + :param border_thickness: Used for the outline_color |
| 59 | + :type border_thickness: int |
| 60 | + :param show_margin: Whether or not to have a margin between the border and |
| 61 | + the fill, or not. |
| 62 | + :type show_margin: bool |
| 63 | + :param direction: The direction of the fill |
| 64 | + :type direction: FillDirection |
| 65 | +
|
21 | 66 | """
|
22 | 67 |
|
23 |
| - def __init__(self): |
24 |
| - """ |
25 |
| - Get stuff, horizontally! |
26 |
| - :param args: |
27 |
| - :param kwargs: |
28 |
| - """ |
| 68 | + # pylint: disable=bad-option-value, unused-argument, too-many-arguments |
| 69 | + def __init__( |
| 70 | + self, |
| 71 | + anchor_position, |
| 72 | + size, |
| 73 | + min_value=0, |
| 74 | + max_value=100, |
| 75 | + progress=0.0, |
| 76 | + value=0, |
| 77 | + bar_color=0x00FF00, |
| 78 | + outline_color=0xFFFFFF, |
| 79 | + fill_color=0x444444, |
| 80 | + border_thickness=1, |
| 81 | + show_margin=True, |
| 82 | + direction=FillDirection.DEFAULT, |
| 83 | + ): |
29 | 84 |
|
30 |
| - super().__init__((0, 0), (100, 20), 0.0) |
| 85 | + super().__init__( |
| 86 | + anchor_position, |
| 87 | + size, |
| 88 | + progress, |
| 89 | + bar_color, |
| 90 | + outline_color, |
| 91 | + fill_color, |
| 92 | + value, |
| 93 | + border_thickness=border_thickness, |
| 94 | + show_margin=show_margin, |
| 95 | + value_range=(min_value, max_value), |
| 96 | + ) |
31 | 97 |
|
32 | 98 | def render(self, _previous_value, _new_value, _progress_value) -> None:
|
33 | 99 | """
|
|
0 commit comments