[api.abstract.view] improvement: allowing the multiple select options width to be defined

This commit is contained in:
Vinicius Moreira
2022-04-16 07:18:05 -03:00
parent a6535c113f
commit 0d79ec39b4
2 changed files with 15 additions and 5 deletions

View File

@@ -140,7 +140,8 @@ class MultipleSelectComponent(InputViewComponent):
def __init__(self, label: Optional[str], options: List[InputOption], default_options: Set[InputOption] = None, def __init__(self, label: Optional[str], options: List[InputOption], default_options: Set[InputOption] = None,
max_per_line: int = 1, tooltip: str = None, spaces: bool = True, max_width: int = -1, max_per_line: int = 1, tooltip: str = None, spaces: bool = True, max_width: int = -1,
max_height: int = -1, id_: str = None, min_width: Optional[int] = None): max_height: int = -1, id_: str = None, min_width: Optional[int] = None,
opt_max_width: Optional[int] = None):
super(MultipleSelectComponent, self).__init__(id_=id_) super(MultipleSelectComponent, self).__init__(id_=id_)
if not options: if not options:
@@ -155,6 +156,7 @@ class MultipleSelectComponent(InputViewComponent):
self.min_width = min_width self.min_width = min_width
self.max_width = max_width self.max_width = max_width
self.max_height = max_height self.max_height = max_height
self.opt_max_width = opt_max_width
def get_selected_values(self) -> list: def get_selected_values(self) -> list:
selected = [] selected = []

View File

@@ -524,10 +524,10 @@ class MultipleSelectQt(QGroupBox):
if model.min_width and model.min_width > 0: if model.min_width and model.min_width > 0:
self.setMinimumWidth(int(model.min_width)) self.setMinimumWidth(int(model.min_width))
if model.max_width > 0: if model.max_width and model.max_width > 0:
self.setMaximumWidth(int(model.max_width)) self.setMaximumWidth(int(model.max_width))
if model.max_height > 0: if model.max_height and model.max_height > 0:
self.setMaximumHeight(int(model.max_height)) self.setMaximumHeight(int(model.max_height))
if model.label: if model.label:
@@ -547,9 +547,13 @@ class MultipleSelectQt(QGroupBox):
comp.setChecked(True) comp.setChecked(True)
widget = QWidget() widget = QWidget()
widget.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
widget.setLayout(QHBoxLayout()) widget.setLayout(QHBoxLayout())
widget.layout().addWidget(comp) widget.layout().addWidget(comp)
if model.opt_max_width and model.opt_max_width > 0:
widget.setMinimumWidth(int(model.opt_max_width))
if op.tooltip: if op.tooltip:
help_icon = QLabel() help_icon = QLabel()
@@ -585,10 +589,10 @@ class FormMultipleSelectQt(QWidget):
if model.min_width and model.min_width > 0: if model.min_width and model.min_width > 0:
self.setMinimumWidth(int(model.min_width)) self.setMinimumWidth(int(model.min_width))
if model.max_width > 0: if model.max_width and model.max_width > 0:
self.setMaximumWidth(int(model.max_width)) self.setMaximumWidth(int(model.max_width))
if model.max_height > 0: if model.max_height and model.max_height > 0:
self.setMaximumHeight(int(model.max_height)) self.setMaximumHeight(int(model.max_height))
self._layout = QGridLayout() self._layout = QGridLayout()
@@ -610,9 +614,13 @@ class FormMultipleSelectQt(QWidget):
comp.setChecked(True) comp.setChecked(True)
widget = QWidget() widget = QWidget()
widget.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
widget.setLayout(QHBoxLayout()) widget.setLayout(QHBoxLayout())
widget.layout().addWidget(comp) widget.layout().addWidget(comp)
if model.opt_max_width and model.opt_max_width > 0:
widget.setMinimumWidth(int(model.opt_max_width))
if op.tooltip: if op.tooltip:
help_icon = QLabel() help_icon = QLabel()