Files
esphome-lsm6ds/esphome/components/lvgl/widgets/container.py
T
0b04361fc0 [lvgl] Layout improvements (#10149)
Co-authored-by: clydeps <U5yx99dok9>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-04 16:39:27 +13:00

40 lines
1.0 KiB
Python

import esphome.config_validation as cv
from esphome.const import CONF_HEIGHT, CONF_WIDTH
from esphome.cpp_generator import MockObj
from ..defines import CONF_CONTAINER, CONF_MAIN, CONF_OBJ, CONF_SCROLLBAR
from ..lv_validation import size
from ..lvcode import lv
from ..types import WidgetType, lv_obj_t
CONTAINER_SCHEMA = cv.Schema(
{
cv.Optional(CONF_HEIGHT, default="100%"): size,
cv.Optional(CONF_WIDTH, default="100%"): size,
}
)
class ContainerType(WidgetType):
"""
A simple container widget that can hold other widgets and which defaults to a 100% size.
Made from an obj with all styles removed
"""
def __init__(self):
super().__init__(
CONF_CONTAINER,
lv_obj_t,
(CONF_MAIN, CONF_SCROLLBAR),
schema=CONTAINER_SCHEMA,
modify_schema={},
lv_name=CONF_OBJ,
)
self.styles = {}
def on_create(self, var: MockObj, config: dict):
lv.obj_remove_style_all(var)
container_spec = ContainerType()