If you pass a list of blocks (such as `Plot` and `Table`) to an app, they are -- by default -- laid out in a single column with a row per block. If you would like to customize the rows and columns, Datapane provides a `Group` block which takes a list of blocks and a number of columns and l
| 150 | |
| 151 | |
| 152 | class Group(ContainerBlock): |
| 153 | """ |
| 154 | If you pass a list of blocks (such as `Plot` and `Table`) to an app, they are -- by default -- laid out in a single column with a row per block. |
| 155 | |
| 156 | If you would like to customize the rows and columns, Datapane provides a `Group` block which takes a list of blocks and a number of columns and lays them out in a grid. |
| 157 | |
| 158 | !!! tip |
| 159 | As `Group` blocks are blocks themselves, they are composable, and you can create more custom layers of nested blocks, for instance nesting 2 rows in the left column of a 2 column layout |
| 160 | """ |
| 161 | |
| 162 | _tag = "Group" |
| 163 | |
| 164 | def __init__( |
| 165 | self, |
| 166 | *arg_blocks: BlockOrPrimitive, |
| 167 | blocks: t.List[BlockOrPrimitive] = None, |
| 168 | name: BlockId = None, |
| 169 | label: t.Optional[str] = None, |
| 170 | widths: t.Optional[t.List[t.Union[int, float]]] = None, |
| 171 | valign: VAlign = VAlign.TOP, |
| 172 | columns: int = 1, |
| 173 | ): |
| 174 | """ |
| 175 | Args: |
| 176 | *arg_blocks: Group to add to report |
| 177 | blocks: Allows providing the report blocks as a single list |
| 178 | name: A unique id for the blocks to aid querying (optional) |
| 179 | label: A label used when displaying the block (optional) |
| 180 | widths: A list of numbers representing the proportion of vertical space given to each column (optional) |
| 181 | valign: The vertical alignment of blocks in the Group (default = VAlign.TOP) |
| 182 | columns: Display the contained blocks, e.g. Plots, using _n_ columns (default = 1), setting to 0 auto-wraps the columns |
| 183 | |
| 184 | !!! note |
| 185 | Group can be passed using either arg parameters or the `blocks` kwarg, e.g. `dp.Group(plot, table, columns=2)` or `dp.Group(blocks=[plot, table], columns=2)`. |
| 186 | """ |
| 187 | |
| 188 | if widths is not None and len(widths) != columns: |
| 189 | raise DPClientError("Group 'widths' list length does not match number of columns") |
| 190 | |
| 191 | # columns = columns or len(self.blocks) |
| 192 | self.columns = columns |
| 193 | super().__init__( |
| 194 | *arg_blocks, blocks=blocks, name=name, label=label, columns=columns, widths=widths, valign=valign |
| 195 | ) |
| 196 | |
| 197 | |
| 198 | class Toggle(ContainerBlock): |
no outgoing calls
no test coverage detected