- Fixed legend not hiding when resizing to 0

- Added the `menu` widget to the topbar.
This commit is contained in:
louisnw
2023-09-06 12:46:52 +01:00
parent 7891c1bc64
commit 8f65a7fc96
4 changed files with 77 additions and 4 deletions

View File

@ -36,6 +36,13 @@ class SwitcherWidget(Widget):
self.run_script(f'{self.id} = {topbar.id}.makeSwitcher({list(options)}, "{default}", "{self.id}")')
class MenuWidget(Widget):
def __init__(self, topbar, options, default, separator, func):
super().__init__(topbar, value=default, func=func)
self.run_script(
f'{self.id} = {topbar.id}.makeMenu({list(options)}, "{default}", {jbool(separator)}, "{self.id}")')
class ButtonWidget(Widget):
def __init__(self, topbar, button, separator, func):
super().__init__(topbar, value=button, func=func)
@ -81,6 +88,10 @@ class TopBar(Pane):
self._create()
self._widgets[name] = SwitcherWidget(self, options, default if default else options[0], func)
def menu(self, name, options: tuple, default: str = None, separator: bool = True, func: callable = None):
self._create()
self._widgets[name] = MenuWidget(self, options, default if default else options[0], separator, func)
def textbox(self, name: str, initial_text: str = ''):
self._create()
self._widgets[name] = TextWidget(self, initial_text)