Closed RhetTbull closed 1 year ago
Something like this
class Tab(text: str, disabled: bool = False):
...
def add_widget(self, widget: Widget):
"""Add a widget to the tab's layout"""
self.layout[0].append(widget)
def __enter__(self):
self.parent = get_parent()
if not isinstance(self.parent, guitk.Notebook):
raise ValueError(...)
push_parent(self)
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.parent._add_tab(self.layout) # adds the tab to the parent Notebook's self.tabs (this method doesn't currently exist)
pop_parent()
return False
The Tab() widgets would add themselves to the parent Notebook's tabs. If the parent isn't a notebook, raise an error.