bosing.Grid¶
- class bosing.Grid(*children, columns=Ellipsis, margin=None, alignment=None, phantom=False, duration=None, max_duration=Ellipsis, min_duration=Ellipsis, label=None)¶
基类:
ElementA grid layout element.
A grid layout has multiple columns and each child element occupies some columns. The width of each column can be specified by
GridLength, which can be:Fixed length in seconds.
- Auto length:
The width is determined by the child element.
- Star length:
The width id determined by remaining duration. For example, if there are two columns with 1* and 2* and the remaining duration is 300 ns, the width of the columns will be 100 ns and 200 ns.
Columns length can be specified with a simplified syntax:
'auto': Auto length.
'x*': x stars.
'x': Fixed length in seconds.
'*': 1 star.
If no columns are provided, the grid layout will have one column with '*'.
Children can be provided as:
GridEntry
Element: The column index is 0 and the span is 1.
tuple[Element, int]: Element and column. The span is 1.
tuple[Element, int, int]: Element, column, and span.
- 参数:
示例
grid = Grid( GridEntry(element1, 0, 1), (element2, 1), (element3, 2, 2), element4, columns=['auto', '1*', '2'], )
- alignment¶
- children¶
- columns¶
- duration¶
- label¶
- margin¶
- max_duration¶
- measure()¶
Measure the minimum total duration required by the element.
This value includes both inner duration and outer margin of the element.
This value is a minimum total duration wanted by the element. If the element is a child of other element, the final total duration will be determined by alignment option and parent container type.
- min_duration¶
- phantom¶
- plot(ax=None, *, channels=None, max_depth=5, show_label=True)¶
Plot arrange result with the element as root.
- 参数:
ax (matplotlib.axes.Axes | None) -- Axes to plot. If
None, matplotlib.pyplot.gca is used.channels (Sequence[str] | None) -- Channels to plot. If
None, all channels are plotted.max_depth (int) -- Maximum depth to plot. Defaults to
5.show_label (bool) -- Whether to show label of elements. Defaults to
True.
- 返回:
Axes with the plot.
- 返回类型:
- with_children(*children)¶
Create a new grid schedule with different children.
Using this method may be more readable than specifying children in the constructor.
grid = Grid(columns=['auto', '*', 'auto']).with_children( element1, (element2, 2), (element3, 0, 3), )