Skip to content

Commit

Permalink
allow tabs to be specified as normal
Browse files Browse the repository at this point in the history
  • Loading branch information
keenanlang committed Dec 16, 2024
1 parent 4a182ab commit 4b514aa
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
50 changes: 47 additions & 3 deletions docs/reference/nodes/layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,11 @@ LED_Grid: !Grid

A widget representing a stack of display areas, with each only being displayed upon the user clicking a corresponding tab button.

The 'children' attribute works slightly differently for this layout. Each individual child node must be a '!Tab', which is a tag
that can be affixed to lists. Each child node will be associated with a specific tab, and selecting that tab will display all the
widgets that are in the corresponding '!Tab' list. If one defines the 'children' attribute as a dictionary, then the key values will
The 'children' attribute works slightly differently for this layout. Each individual child node must be a '!Tab'. Tabs are pass-through
Group nodes, with the children attribute specifying the widgets that are displayed for that tag.

Each child node in the TabbedGroup will be associated with a specific tab, and selecting that tab will display all the
widgets that are in the corresponding '!Tab'. If one defines the 'children' attribute as a dictionary, then the key values will
be used as the tab names. If 'children' is a list, then the tabs will display as "Tab 1", "Tab 2", etc.

The macros __parentwidth__ and __parentheight__ will be passed along to children widgets, these are set to the size of the display
Expand All @@ -362,6 +364,48 @@ pane, which will depend on the values of certain attributes.

* **Example**

```yaml
- !TabbedGroup
geometry: 570x200
inset: 5
offset: 3
border-color: *header_blue
tab-color: *header_blue
foreground: *white
selected: $3970C4
font: -DejaVu Sans Mono - Bold - 9
children:
Motors: !Tab
children:
- !AStretch:Spacer
Optics: !Tab
children:
- !AStretch:Spacer
Detectors: !Tab
children:
- !AStretch:Spacer
Direct I/O: !Tab
children:
- !AStretch:Spacer
Devices: !Tab
children:
- !AStretch:Spacer
Tools: !Tab
children:
- !AStretch:Spacer
```

To save space, the !Tab node type can be directly applied to the list of children nodes.

```yaml
- !TabbedGroup
geometry: 570x200
Expand Down
3 changes: 2 additions & 1 deletion gestalt/Stylesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ def read_tab_node(loader, node):
params = loader.construct_sequence(node, deep=True)
return GroupNode("TabNode", layout={"children" : params}, loc=node.start_mark)
except:
return None
params = loader.construct_mapping(node, deep=True)
return GroupNode("TabNode", layout=params, loc=node.start_mark)


recognized_types = (
Expand Down

0 comments on commit 4b514aa

Please sign in to comment.