Skip to content

Commit

Permalink
feat: initial implementation #1887
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-mihok committed Mar 23, 2023
1 parent 2091ab4 commit 7e24a7c
Show file tree
Hide file tree
Showing 8 changed files with 352 additions and 8 deletions.
89 changes: 89 additions & 0 deletions py/h2o_lightwave/h2o_lightwave/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2571,6 +2571,85 @@ def load(__d: Dict) -> 'ColorPicker':
)


class ButtonCommand:
"""No documentation available.
"""
def __init__(
self,
name: str,
label: Optional[str] = None,
caption: Optional[str] = None,
icon: Optional[str] = None,
value: Optional[str] = None,
path: Optional[str] = None,
):
_guard_scalar('ButtonCommand.name', name, (str,), True, False, False)
_guard_scalar('ButtonCommand.label', label, (str,), False, True, False)
_guard_scalar('ButtonCommand.caption', caption, (str,), False, True, False)
_guard_scalar('ButtonCommand.icon', icon, (str,), False, True, False)
_guard_scalar('ButtonCommand.value', value, (str,), False, True, False)
_guard_scalar('ButtonCommand.path', path, (str,), False, True, False)
self.name = name
"""An identifying name for this component. If the name is prefixed with a '#', the command sets the location hash to the name when executed."""
self.label = label
"""The text displayed for this command."""
self.caption = caption
"""The caption for this command (typically a tooltip)."""
self.icon = icon
"""The icon to be displayed for this command."""
self.value = value
"""Data associated with this command, if any."""
self.path = path
"""The path or URL to link to. If specified, the `name` is ignored. The URL is opened in a new browser window or tab."""

def dump(self) -> Dict:
"""Returns the contents of this object as a dict."""
_guard_scalar('ButtonCommand.name', self.name, (str,), True, False, False)
_guard_scalar('ButtonCommand.label', self.label, (str,), False, True, False)
_guard_scalar('ButtonCommand.caption', self.caption, (str,), False, True, False)
_guard_scalar('ButtonCommand.icon', self.icon, (str,), False, True, False)
_guard_scalar('ButtonCommand.value', self.value, (str,), False, True, False)
_guard_scalar('ButtonCommand.path', self.path, (str,), False, True, False)
return _dump(
name=self.name,
label=self.label,
caption=self.caption,
icon=self.icon,
value=self.value,
path=self.path,
)

@staticmethod
def load(__d: Dict) -> 'ButtonCommand':
"""Creates an instance of this class using the contents of a dict."""
__d_name: Any = __d.get('name')
_guard_scalar('ButtonCommand.name', __d_name, (str,), True, False, False)
__d_label: Any = __d.get('label')
_guard_scalar('ButtonCommand.label', __d_label, (str,), False, True, False)
__d_caption: Any = __d.get('caption')
_guard_scalar('ButtonCommand.caption', __d_caption, (str,), False, True, False)
__d_icon: Any = __d.get('icon')
_guard_scalar('ButtonCommand.icon', __d_icon, (str,), False, True, False)
__d_value: Any = __d.get('value')
_guard_scalar('ButtonCommand.value', __d_value, (str,), False, True, False)
__d_path: Any = __d.get('path')
_guard_scalar('ButtonCommand.path', __d_path, (str,), False, True, False)
name: str = __d_name
label: Optional[str] = __d_label
caption: Optional[str] = __d_caption
icon: Optional[str] = __d_icon
value: Optional[str] = __d_value
path: Optional[str] = __d_path
return ButtonCommand(
name,
label,
caption,
icon,
value,
path,
)


class Button:
"""Create a button.

Expand Down Expand Up @@ -2603,6 +2682,7 @@ def __init__(
visible: Optional[bool] = None,
tooltip: Optional[str] = None,
path: Optional[str] = None,
commands: Optional[List[ButtonCommand]] = None,
):
_guard_scalar('Button.name', name, (str,), True, False, False)
_guard_scalar('Button.label', label, (str,), False, True, False)
Expand All @@ -2616,6 +2696,7 @@ def __init__(
_guard_scalar('Button.visible', visible, (bool,), False, True, False)
_guard_scalar('Button.tooltip', tooltip, (str,), False, True, False)
_guard_scalar('Button.path', path, (str,), False, True, False)
_guard_vector('Button.commands', commands, (ButtonCommand,), False, True, False)
self.name = name
"""An identifying name for this component. If the name is prefixed with a '#', the button sets the location hash to the name when clicked."""
self.label = label
Expand All @@ -2640,6 +2721,8 @@ def __init__(
"""An optional tooltip message displayed when a user clicks the help icon to the right of the component."""
self.path = path
"""The path or URL to link to. If specified, the `name` is ignored. The URL is opened in a new browser window or tab."""
self.commands = commands
"""The menu with button actions."""

def dump(self) -> Dict:
"""Returns the contents of this object as a dict."""
Expand All @@ -2655,6 +2738,7 @@ def dump(self) -> Dict:
_guard_scalar('Button.visible', self.visible, (bool,), False, True, False)
_guard_scalar('Button.tooltip', self.tooltip, (str,), False, True, False)
_guard_scalar('Button.path', self.path, (str,), False, True, False)
_guard_vector('Button.commands', self.commands, (ButtonCommand,), False, True, False)
return _dump(
name=self.name,
label=self.label,
Expand All @@ -2668,6 +2752,7 @@ def dump(self) -> Dict:
visible=self.visible,
tooltip=self.tooltip,
path=self.path,
commands=None if self.commands is None else [__e.dump() for __e in self.commands],
)

@staticmethod
Expand Down Expand Up @@ -2697,6 +2782,8 @@ def load(__d: Dict) -> 'Button':
_guard_scalar('Button.tooltip', __d_tooltip, (str,), False, True, False)
__d_path: Any = __d.get('path')
_guard_scalar('Button.path', __d_path, (str,), False, True, False)
__d_commands: Any = __d.get('commands')
_guard_vector('Button.commands', __d_commands, (dict,), False, True, False)
name: str = __d_name
label: Optional[str] = __d_label
caption: Optional[str] = __d_caption
Expand All @@ -2709,6 +2796,7 @@ def load(__d: Dict) -> 'Button':
visible: Optional[bool] = __d_visible
tooltip: Optional[str] = __d_tooltip
path: Optional[str] = __d_path
commands: Optional[List[ButtonCommand]] = None if __d_commands is None else [ButtonCommand.load(__e) for __e in __d_commands]
return Button(
name,
label,
Expand All @@ -2722,6 +2810,7 @@ def load(__d: Dict) -> 'Button':
visible,
tooltip,
path,
commands,
)


Expand Down
33 changes: 33 additions & 0 deletions py/h2o_lightwave/h2o_lightwave/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,36 @@ def color_picker(
))


def button_command(
name: str,
label: Optional[str] = None,
caption: Optional[str] = None,
icon: Optional[str] = None,
value: Optional[str] = None,
path: Optional[str] = None,
) -> ButtonCommand:
"""No documentation available.
Args:
name: An identifying name for this component. If the name is prefixed with a '#', the command sets the location hash to the name when executed.
label: The text displayed for this command.
caption: The caption for this command (typically a tooltip).
icon: The icon to be displayed for this command.
value: Data associated with this command, if any.
path: The path or URL to link to. If specified, the `name` is ignored. The URL is opened in a new browser window or tab.
Returns:
A `h2o_wave.types.ButtonCommand` instance.
"""
return ButtonCommand(
name,
label,
caption,
icon,
value,
path,
)


def button(
name: str,
label: Optional[str] = None,
Expand All @@ -998,6 +1028,7 @@ def button(
visible: Optional[bool] = None,
tooltip: Optional[str] = None,
path: Optional[str] = None,
commands: Optional[List[ButtonCommand]] = None,
) -> Component:
"""Create a button.
Expand Down Expand Up @@ -1029,6 +1060,7 @@ def button(
visible: True if the component should be visible. Defaults to True.
tooltip: An optional tooltip message displayed when a user clicks the help icon to the right of the component.
path: The path or URL to link to. If specified, the `name` is ignored. The URL is opened in a new browser window or tab.
commands: The menu with button actions.
Returns:
A `h2o_wave.types.Button` instance.
"""
Expand All @@ -1045,6 +1077,7 @@ def button(
visible,
tooltip,
path,
commands,
))


Expand Down
89 changes: 89 additions & 0 deletions py/h2o_wave/h2o_wave/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2571,6 +2571,85 @@ def load(__d: Dict) -> 'ColorPicker':
)


class ButtonCommand:
"""No documentation available.
"""
def __init__(
self,
name: str,
label: Optional[str] = None,
caption: Optional[str] = None,
icon: Optional[str] = None,
value: Optional[str] = None,
path: Optional[str] = None,
):
_guard_scalar('ButtonCommand.name', name, (str,), True, False, False)
_guard_scalar('ButtonCommand.label', label, (str,), False, True, False)
_guard_scalar('ButtonCommand.caption', caption, (str,), False, True, False)
_guard_scalar('ButtonCommand.icon', icon, (str,), False, True, False)
_guard_scalar('ButtonCommand.value', value, (str,), False, True, False)
_guard_scalar('ButtonCommand.path', path, (str,), False, True, False)
self.name = name
"""An identifying name for this component. If the name is prefixed with a '#', the command sets the location hash to the name when executed."""
self.label = label
"""The text displayed for this command."""
self.caption = caption
"""The caption for this command (typically a tooltip)."""
self.icon = icon
"""The icon to be displayed for this command."""
self.value = value
"""Data associated with this command, if any."""
self.path = path
"""The path or URL to link to. If specified, the `name` is ignored. The URL is opened in a new browser window or tab."""

def dump(self) -> Dict:
"""Returns the contents of this object as a dict."""
_guard_scalar('ButtonCommand.name', self.name, (str,), True, False, False)
_guard_scalar('ButtonCommand.label', self.label, (str,), False, True, False)
_guard_scalar('ButtonCommand.caption', self.caption, (str,), False, True, False)
_guard_scalar('ButtonCommand.icon', self.icon, (str,), False, True, False)
_guard_scalar('ButtonCommand.value', self.value, (str,), False, True, False)
_guard_scalar('ButtonCommand.path', self.path, (str,), False, True, False)
return _dump(
name=self.name,
label=self.label,
caption=self.caption,
icon=self.icon,
value=self.value,
path=self.path,
)

@staticmethod
def load(__d: Dict) -> 'ButtonCommand':
"""Creates an instance of this class using the contents of a dict."""
__d_name: Any = __d.get('name')
_guard_scalar('ButtonCommand.name', __d_name, (str,), True, False, False)
__d_label: Any = __d.get('label')
_guard_scalar('ButtonCommand.label', __d_label, (str,), False, True, False)
__d_caption: Any = __d.get('caption')
_guard_scalar('ButtonCommand.caption', __d_caption, (str,), False, True, False)
__d_icon: Any = __d.get('icon')
_guard_scalar('ButtonCommand.icon', __d_icon, (str,), False, True, False)
__d_value: Any = __d.get('value')
_guard_scalar('ButtonCommand.value', __d_value, (str,), False, True, False)
__d_path: Any = __d.get('path')
_guard_scalar('ButtonCommand.path', __d_path, (str,), False, True, False)
name: str = __d_name
label: Optional[str] = __d_label
caption: Optional[str] = __d_caption
icon: Optional[str] = __d_icon
value: Optional[str] = __d_value
path: Optional[str] = __d_path
return ButtonCommand(
name,
label,
caption,
icon,
value,
path,
)


class Button:
"""Create a button.

Expand Down Expand Up @@ -2603,6 +2682,7 @@ def __init__(
visible: Optional[bool] = None,
tooltip: Optional[str] = None,
path: Optional[str] = None,
commands: Optional[List[ButtonCommand]] = None,
):
_guard_scalar('Button.name', name, (str,), True, False, False)
_guard_scalar('Button.label', label, (str,), False, True, False)
Expand All @@ -2616,6 +2696,7 @@ def __init__(
_guard_scalar('Button.visible', visible, (bool,), False, True, False)
_guard_scalar('Button.tooltip', tooltip, (str,), False, True, False)
_guard_scalar('Button.path', path, (str,), False, True, False)
_guard_vector('Button.commands', commands, (ButtonCommand,), False, True, False)
self.name = name
"""An identifying name for this component. If the name is prefixed with a '#', the button sets the location hash to the name when clicked."""
self.label = label
Expand All @@ -2640,6 +2721,8 @@ def __init__(
"""An optional tooltip message displayed when a user clicks the help icon to the right of the component."""
self.path = path
"""The path or URL to link to. If specified, the `name` is ignored. The URL is opened in a new browser window or tab."""
self.commands = commands
"""The menu with button actions."""

def dump(self) -> Dict:
"""Returns the contents of this object as a dict."""
Expand All @@ -2655,6 +2738,7 @@ def dump(self) -> Dict:
_guard_scalar('Button.visible', self.visible, (bool,), False, True, False)
_guard_scalar('Button.tooltip', self.tooltip, (str,), False, True, False)
_guard_scalar('Button.path', self.path, (str,), False, True, False)
_guard_vector('Button.commands', self.commands, (ButtonCommand,), False, True, False)
return _dump(
name=self.name,
label=self.label,
Expand All @@ -2668,6 +2752,7 @@ def dump(self) -> Dict:
visible=self.visible,
tooltip=self.tooltip,
path=self.path,
commands=None if self.commands is None else [__e.dump() for __e in self.commands],
)

@staticmethod
Expand Down Expand Up @@ -2697,6 +2782,8 @@ def load(__d: Dict) -> 'Button':
_guard_scalar('Button.tooltip', __d_tooltip, (str,), False, True, False)
__d_path: Any = __d.get('path')
_guard_scalar('Button.path', __d_path, (str,), False, True, False)
__d_commands: Any = __d.get('commands')
_guard_vector('Button.commands', __d_commands, (dict,), False, True, False)
name: str = __d_name
label: Optional[str] = __d_label
caption: Optional[str] = __d_caption
Expand All @@ -2709,6 +2796,7 @@ def load(__d: Dict) -> 'Button':
visible: Optional[bool] = __d_visible
tooltip: Optional[str] = __d_tooltip
path: Optional[str] = __d_path
commands: Optional[List[ButtonCommand]] = None if __d_commands is None else [ButtonCommand.load(__e) for __e in __d_commands]
return Button(
name,
label,
Expand All @@ -2722,6 +2810,7 @@ def load(__d: Dict) -> 'Button':
visible,
tooltip,
path,
commands,
)


Expand Down
Loading

0 comments on commit 7e24a7c

Please sign in to comment.