From 656810ffe5ff44a99059b8b012fd550a95dc5181 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Mon, 21 Feb 2022 12:37:00 -0300 Subject: [PATCH] [view] improvement: able to define min width for form component --- bauh/api/abstract/view.py | 4 +++- bauh/view/qt/components.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bauh/api/abstract/view.py b/bauh/api/abstract/view.py index e851d332..f476606e 100644 --- a/bauh/api/abstract/view.py +++ b/bauh/api/abstract/view.py @@ -204,12 +204,14 @@ class TextInputComponent(ViewComponent): class FormComponent(ViewComponent): - def __init__(self, components: List[ViewComponent], label: str = None, spaces: bool = True, id_: str = None): + def __init__(self, components: List[ViewComponent], label: str = None, spaces: bool = True, id_: str = None, + min_width: Optional[int] = None): super(FormComponent, self).__init__(id_=id_) self.label = label self.spaces = spaces self.components = components self.component_map = {c.id: c for c in components if c.id} if components else None + self.min_width = min_width def get_component(self, id_: str) -> Optional[ViewComponent]: if self.component_map: diff --git a/bauh/view/qt/components.py b/bauh/view/qt/components.py index dc09834a..43a23c24 100644 --- a/bauh/view/qt/components.py +++ b/bauh/view/qt/components.py @@ -713,6 +713,9 @@ class FormQt(QGroupBox): self.i18n = i18n self.setLayout(QFormLayout()) + if model.min_width and model.min_width > 0: + self.setMinimumWidth(model.min_width) + if model.spaces: self.layout().addRow(QLabel(), QLabel())