1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-29 22:24:26 +00:00

[lvgl] Fix: allow full range of styles on dropdown list. (#7552)

This commit is contained in:
Clyde Stubbs
2024-10-07 13:43:41 +11:00
committed by GitHub
parent 03a95ee05f
commit 6a2ed8241e
4 changed files with 58 additions and 2 deletions

View File

@@ -242,6 +242,8 @@ def pixels_or_percent_validator(value):
"""A length in one axis - either a number (pixels) or a percentage"""
if value == SCHEMA_EXTRACT:
return ["pixels", "..%"]
if isinstance(value, str) and value.lower().endswith("px"):
value = cv.int_(value[:-2])
value = cv.Any(cv.int_, cv.percentage)(value)
if isinstance(value, int):
return value

View File

@@ -6,6 +6,8 @@ from ..defines import (
CONF_DIR,
CONF_INDICATOR,
CONF_MAIN,
CONF_SCROLLBAR,
CONF_SELECTED,
CONF_SELECTED_INDEX,
CONF_SYMBOL,
DIRECTIONS,
@@ -23,7 +25,9 @@ CONF_DROPDOWN_LIST = "dropdown_list"
lv_dropdown_t = LvSelect("lv_dropdown_t")
lv_dropdown_list_t = LvType("lv_dropdown_list_t")
dropdown_list_spec = WidgetType(CONF_DROPDOWN_LIST, lv_dropdown_list_t, (CONF_MAIN,))
dropdown_list_spec = WidgetType(
CONF_DROPDOWN_LIST, lv_dropdown_list_t, (CONF_MAIN, CONF_SELECTED, CONF_SCROLLBAR)
)
DROPDOWN_BASE_SCHEMA = cv.Schema(
{

View File

@@ -309,6 +309,6 @@ async def set_indicator_values(meter, indicator, config):
lv.meter_set_indicator_start_value(meter, indicator, start_value)
if end_value is not None:
lv.meter_set_indicator_end_value(meter, indicator, end_value)
if opa := config.get(CONF_OPA):
if (opa := config.get(CONF_OPA)) is not None:
lv_assign(indicator.opa, await opacity.process(opa))
lv_obj.invalidate(meter)