File size: 6,129 Bytes
9ff4bea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
from __future__ import annotations

from typing import TYPE_CHECKING

from .api import Container, View
from .components.container_kind import ContainerKind

if TYPE_CHECKING:
    from collections.abc import Iterable

    from ..encodings import BoolLike, Float32ArrayLike, Utf8Like


class Horizontal(Container):
    """A horizontal container."""

    def __init__(
        self,
        *args: Container | View,
        contents: Iterable[Container | View] | None = None,
        column_shares: Float32ArrayLike | None = None,
        name: Utf8Like | None = None,
        visible: BoolLike | None = None,
    ) -> None:
        """
        Construct a new horizontal container.

        Parameters
        ----------
        *args:
            All positional arguments are forwarded to the `contents` parameter for convenience.
        contents:
            The contents of the container. Each item in the iterable must be a `View` or a `Container`.
            This can only be used if no positional arguments are provided.
        column_shares
            The layout shares of the columns in the container. The share is used to determine what fraction of the total width each
            column should take up. The column with index `i` will take up the fraction `shares[i] / total_shares`.
        name
            The name of the container
        visible:
            Whether this container is visible.

            Defaults to true if not specified.

        """
        super().__init__(
            *args,
            contents=contents,
            kind=ContainerKind.Horizontal,
            column_shares=column_shares,
            name=name,
            visible=visible,
        )


class Vertical(Container):
    """A vertical container."""

    def __init__(
        self,
        *args: Container | View,
        contents: Iterable[Container | View] | None = None,
        row_shares: Float32ArrayLike | None = None,
        name: Utf8Like | None = None,
        visible: BoolLike | None = None,
    ) -> None:
        """
        Construct a new vertical container.

        Parameters
        ----------
        *args:
            All positional arguments are forwarded to the `contents` parameter for convenience.
        contents:
            The contents of the container. Each item in the iterable must be a `View` or a `Container`.
            This can only be used if no positional arguments are provided.
        row_shares
            The layout shares of the rows in the container. The share is used to determine what fraction of the total height each
            row should take up. The row with index `i` will take up the fraction `shares[i] / total_shares`.
        name
            The name of the container
        visible:
            Whether this container is visible.

            Defaults to true if not specified.

        """
        super().__init__(
            *args,
            contents=contents,
            kind=ContainerKind.Vertical,
            row_shares=row_shares,
            name=name,
            visible=visible,
        )


class Grid(Container):
    """A grid container."""

    def __init__(
        self,
        *args: Container | View,
        contents: Iterable[Container | View] | None = None,
        column_shares: Float32ArrayLike | None = None,
        row_shares: Float32ArrayLike | None = None,
        grid_columns: int | None = None,
        name: Utf8Like | None = None,
        visible: BoolLike | None = None,
    ) -> None:
        """
        Construct a new grid container.

        Parameters
        ----------
        *args:
            All positional arguments are forwarded to the `contents` parameter for convenience.
        contents:
            The contents of the container. Each item in the iterable must be a `View` or a `Container`.
            This can only be used if no positional arguments are provided.
        column_shares
            The layout shares of the columns in the container. The share is used to determine what fraction of the total width each
            column should take up. The column with index `i` will take up the fraction `shares[i] / total_shares`.
        row_shares
            The layout shares of the rows in the container. The share is used to determine what fraction of the total height each
            row should take up. The row with index `i` will take up the fraction `shares[i] / total_shares`.
        grid_columns
            The number of columns in the grid.
        name
            The name of the container
        visible:
            Whether this container is visible.

            Defaults to true if not specified.

        """
        super().__init__(
            *args,
            contents=contents,
            kind=ContainerKind.Grid,
            column_shares=column_shares,
            row_shares=row_shares,
            grid_columns=grid_columns,
            name=name,
            visible=visible,
        )


class Tabs(Container):
    """A tab container."""

    def __init__(
        self,
        *args: Container | View,
        contents: Iterable[Container | View] | None = None,
        active_tab: int | str | None = None,
        name: Utf8Like | None = None,
        visible: BoolLike | None = None,
    ) -> None:
        """
        Construct a new tab container.

        Parameters
        ----------
        *args:
            All positional arguments are forwarded to the `contents` parameter for convenience.
        contents:
            The contents of the container. Each item in the iterable must be a `View` or a `Container`.
            This can only be used if no positional arguments are provided.
        active_tab:
            The index or name of the active tab.
        name
            The name of the container
        visible:
            Whether this container is visible.

            Defaults to true if not specified.

        """
        super().__init__(
            *args,
            contents=contents,
            kind=ContainerKind.Tabs,
            active_tab=active_tab,
            name=name,
            visible=visible,
        )