Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/issue-2180
Browse files Browse the repository at this point in the history
  • Loading branch information
sulhicader committed Jan 31, 2024
2 parents 293a3ef + 3a9f4b7 commit 9b5f402
Show file tree
Hide file tree
Showing 23 changed files with 658 additions and 197 deletions.
2 changes: 2 additions & 0 deletions py/examples/textbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ async def serve(q: Q):
ui.text(f'textbox_spellcheck_disabled={q.args.textbox_spellcheck_disabled}'),
ui.text(f'textbox_numeric={q.args.textbox_numeric}'),
ui.text(f'textbox_tel={q.args.textbox_tel}'),
ui.text(f'textbox_password={q.args.textbox_password}'),
ui.button(name='show_form', label='Back', primary=True),
]
else:
Expand All @@ -44,6 +45,7 @@ async def serve(q: Q):
ui.textbox(name='textbox_spellcheck_disabled', label='Spellcheck disabled', spellcheck=False),
ui.textbox(name='textbox_numeric', label='With numeric keyboard (iOS, Android)', type='number'),
ui.textbox(name='textbox_tel', label='With telephone keyboard (iOS, Android)', type='tel'),
ui.textbox(name='textbox_password', label='Password', password=True),
ui.button(name='show_inputs', label='Submit', primary=True),
])
await q.page.save()
30 changes: 30 additions & 0 deletions py/h2o_lightwave/h2o_lightwave/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5842,12 +5842,14 @@ def __init__(
caption: Optional[str] = None,
icon: Optional[str] = None,
icon_color: Optional[str] = None,
name: Optional[str] = None,
):
_guard_scalar('Stat.label', label, (str,), False, False, False)
_guard_scalar('Stat.value', value, (str,), False, True, False)
_guard_scalar('Stat.caption', caption, (str,), False, True, False)
_guard_scalar('Stat.icon', icon, (str,), False, True, False)
_guard_scalar('Stat.icon_color', icon_color, (str,), False, True, False)
_guard_scalar('Stat.name', name, (str,), False, True, False)
self.label = label
"""The label for the metric."""
self.value = value
Expand All @@ -5858,6 +5860,8 @@ def __init__(
"""An optional icon, displayed next to the label."""
self.icon_color = icon_color
"""The color of the icon."""
self.name = name
"""An identifying name for this item."""

def dump(self) -> Dict:
"""Returns the contents of this object as a dict."""
Expand All @@ -5866,12 +5870,14 @@ def dump(self) -> Dict:
_guard_scalar('Stat.caption', self.caption, (str,), False, True, False)
_guard_scalar('Stat.icon', self.icon, (str,), False, True, False)
_guard_scalar('Stat.icon_color', self.icon_color, (str,), False, True, False)
_guard_scalar('Stat.name', self.name, (str,), False, True, False)
return _dump(
label=self.label,
value=self.value,
caption=self.caption,
icon=self.icon,
icon_color=self.icon_color,
name=self.name,
)

@staticmethod
Expand All @@ -5887,17 +5893,21 @@ def load(__d: Dict) -> 'Stat':
_guard_scalar('Stat.icon', __d_icon, (str,), False, True, False)
__d_icon_color: Any = __d.get('icon_color')
_guard_scalar('Stat.icon_color', __d_icon_color, (str,), False, True, False)
__d_name: Any = __d.get('name')
_guard_scalar('Stat.name', __d_name, (str,), False, True, False)
label: str = __d_label
value: Optional[str] = __d_value
caption: Optional[str] = __d_caption
icon: Optional[str] = __d_icon
icon_color: Optional[str] = __d_icon_color
name: Optional[str] = __d_name
return Stat(
label,
value,
caption,
icon,
icon_color,
name,
)


Expand All @@ -5922,12 +5932,14 @@ def __init__(
inset: Optional[bool] = None,
width: Optional[str] = None,
visible: Optional[bool] = None,
name: Optional[str] = None,
):
_guard_vector('Stats.items', items, (Stat,), False, False, False)
_guard_enum('Stats.justify', justify, _StatsJustify, True)
_guard_scalar('Stats.inset', inset, (bool,), False, True, False)
_guard_scalar('Stats.width', width, (str,), False, True, False)
_guard_scalar('Stats.visible', visible, (bool,), False, True, False)
_guard_scalar('Stats.name', name, (str,), False, True, False)
self.items = items
"""The individual stats to be displayed."""
self.justify = justify
Expand All @@ -5938,6 +5950,8 @@ def __init__(
"""The width of the stats, e.g. '100px'."""
self.visible = visible
"""True if the component should be visible. Defaults to True."""
self.name = name
"""An identifying name for this component."""

def dump(self) -> Dict:
"""Returns the contents of this object as a dict."""
Expand All @@ -5946,12 +5960,14 @@ def dump(self) -> Dict:
_guard_scalar('Stats.inset', self.inset, (bool,), False, True, False)
_guard_scalar('Stats.width', self.width, (str,), False, True, False)
_guard_scalar('Stats.visible', self.visible, (bool,), False, True, False)
_guard_scalar('Stats.name', self.name, (str,), False, True, False)
return _dump(
items=[__e.dump() for __e in self.items],
justify=self.justify,
inset=self.inset,
width=self.width,
visible=self.visible,
name=self.name,
)

@staticmethod
Expand All @@ -5967,17 +5983,21 @@ def load(__d: Dict) -> 'Stats':
_guard_scalar('Stats.width', __d_width, (str,), False, True, False)
__d_visible: Any = __d.get('visible')
_guard_scalar('Stats.visible', __d_visible, (bool,), False, True, False)
__d_name: Any = __d.get('name')
_guard_scalar('Stats.name', __d_name, (str,), False, True, False)
items: List[Stat] = [Stat.load(__e) for __e in __d_items]
justify: Optional[str] = __d_justify
inset: Optional[bool] = __d_inset
width: Optional[str] = __d_width
visible: Optional[bool] = __d_visible
name: Optional[str] = __d_name
return Stats(
items,
justify,
inset,
width,
visible,
name,
)


Expand Down Expand Up @@ -12713,27 +12733,33 @@ def __init__(
self,
box: str,
items: List[Stat],
name: Optional[str] = None,
commands: Optional[List[Command]] = None,
):
_guard_scalar('TallStatsCard.box', box, (str,), False, False, False)
_guard_vector('TallStatsCard.items', items, (Stat,), False, False, False)
_guard_scalar('TallStatsCard.name', name, (str,), False, True, False)
_guard_vector('TallStatsCard.commands', commands, (Command,), False, True, False)
self.box = box
"""A string indicating how to place this component on the page."""
self.items = items
"""The individual stats to be displayed."""
self.name = name
"""An identifying name for this component."""
self.commands = commands
"""Contextual menu commands for this component."""

def dump(self) -> Dict:
"""Returns the contents of this object as a dict."""
_guard_scalar('TallStatsCard.box', self.box, (str,), False, False, False)
_guard_vector('TallStatsCard.items', self.items, (Stat,), False, False, False)
_guard_scalar('TallStatsCard.name', self.name, (str,), False, True, False)
_guard_vector('TallStatsCard.commands', self.commands, (Command,), False, True, False)
return _dump(
view='tall_stats',
box=self.box,
items=[__e.dump() for __e in self.items],
name=self.name,
commands=None if self.commands is None else [__e.dump() for __e in self.commands],
)

Expand All @@ -12744,14 +12770,18 @@ def load(__d: Dict) -> 'TallStatsCard':
_guard_scalar('TallStatsCard.box', __d_box, (str,), False, False, False)
__d_items: Any = __d.get('items')
_guard_vector('TallStatsCard.items', __d_items, (dict,), False, False, False)
__d_name: Any = __d.get('name')
_guard_scalar('TallStatsCard.name', __d_name, (str,), False, True, False)
__d_commands: Any = __d.get('commands')
_guard_vector('TallStatsCard.commands', __d_commands, (dict,), False, True, False)
box: str = __d_box
items: List[Stat] = [Stat.load(__e) for __e in __d_items]
name: Optional[str] = __d_name
commands: Optional[List[Command]] = None if __d_commands is None else [Command.load(__e) for __e in __d_commands]
return TallStatsCard(
box,
items,
name,
commands,
)

Expand Down
9 changes: 9 additions & 0 deletions py/h2o_lightwave/h2o_lightwave/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2159,6 +2159,7 @@ def stat(
caption: Optional[str] = None,
icon: Optional[str] = None,
icon_color: Optional[str] = None,
name: Optional[str] = None,
) -> Stat:
"""Create a stat (a label-value pair) for displaying a metric.
Expand All @@ -2168,6 +2169,7 @@ def stat(
caption: The caption displayed below the primary value.
icon: An optional icon, displayed next to the label.
icon_color: The color of the icon.
name: An identifying name for this item.
Returns:
A `h2o_wave.types.Stat` instance.
"""
Expand All @@ -2177,6 +2179,7 @@ def stat(
caption,
icon,
icon_color,
name,
)


Expand All @@ -2186,6 +2189,7 @@ def stats(
inset: Optional[bool] = None,
width: Optional[str] = None,
visible: Optional[bool] = None,
name: Optional[str] = None,
) -> Component:
"""Create a set of stats laid out horizontally.
Expand All @@ -2195,6 +2199,7 @@ def stats(
inset: Whether to display the stats with a contrasting background.
width: The width of the stats, e.g. '100px'.
visible: True if the component should be visible. Defaults to True.
name: An identifying name for this component.
Returns:
A `h2o_wave.types.Stats` instance.
"""
Expand All @@ -2204,6 +2209,7 @@ def stats(
inset,
width,
visible,
name,
))


Expand Down Expand Up @@ -4507,20 +4513,23 @@ def tall_series_stat_card(
def tall_stats_card(
box: str,
items: List[Stat],
name: Optional[str] = None,
commands: Optional[List[Command]] = None,
) -> TallStatsCard:
"""Create a vertical label-value pairs collection. Icon in `ui.stat` is not yet supported in this card.
Args:
box: A string indicating how to place this component on the page.
items: The individual stats to be displayed.
name: An identifying name for this component.
commands: Contextual menu commands for this component.
Returns:
A `h2o_wave.types.TallStatsCard` instance.
"""
return TallStatsCard(
box,
items,
name,
commands,
)

Expand Down
3 changes: 2 additions & 1 deletion py/h2o_wave/h2o_wave/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def run(app: str, no_reload: bool, no_autostart: bool):
waved_path = os.path.join(sys.exec_prefix, 'waved.exe' if IS_WINDOWS else 'waved')
# OS agnostic wheels do not include waved - needed for HAC.
is_waved_present = os.path.isfile(waved_path)
is_auto_started = server_not_running

try:
if autostart and is_waved_present and server_not_running:
Expand All @@ -175,7 +176,7 @@ def run(app: str, no_reload: bool, no_autostart: bool):
print('Could not connect to Wave server. Please start the Wave server (waved or waved.exe) prior to running any app.')
return

if not os.environ.get('H2O_WAVE_WAVED_DIR') and is_waved_present:
if not os.environ.get('H2O_WAVE_WAVED_DIR') and is_auto_started:
os.environ['H2O_WAVE_WAVED_DIR'] = sys.exec_prefix
reload_exclude = os.environ.get('H2O_WAVE_RELOAD_EXCLUDE', None)
if reload_exclude:
Expand Down
Loading

0 comments on commit 9b5f402

Please sign in to comment.