Skip to content

Commit

Permalink
Make kwargs of container-like widgets consistent (#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjinliu authored Oct 23, 2023
1 parent 9a58c9c commit 48c94e2
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/magicgui/widgets/_concrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,28 +611,24 @@ class ListEdit(Container[ValueWidget[_V]]):
----------
value : Iterable, optional
The starting value for the widget.
layout : str, optional
The layout for the container. must be one of ``{'horizontal',
'vertical'}``. by default "horizontal"
nullable : bool
If `True`, the widget will accepts `None` as a valid value, by default `False`.
options: dict, optional
Widget options of child widgets.
**kwargs : Any
All additional keyword arguments are passed to `Container` constructor.
"""

def __init__( # type: ignore [misc] # overlap between names
def __init__(
self,
value: Iterable[_V] | _Undefined = Undefined,
layout: str = "horizontal",
nullable: bool = False,
options: dict | None = None,
**kwargs: Unpack[ContainerKwargs],
**container_kwargs: Unpack[ContainerKwargs],
) -> None:
self._args_type: type | None = None
self._nullable = nullable
super().__init__(layout=layout, labels=False, **kwargs)
container_kwargs.setdefault("layout", "horizontal")
container_kwargs.setdefault("labels", False)
super().__init__(**container_kwargs)
self.margins = (0, 0, 0, 0)

if not isinstance(value, _Undefined):
Expand All @@ -651,7 +647,7 @@ def __init__( # type: ignore [misc] # overlap between names
button_plus = PushButton(text="+", name="plus")
button_minus = PushButton(text="-", name="minus")

if layout == "horizontal":
if self.layout == "horizontal":
button_plus.max_width = 40
button_minus.max_width = 40

Expand Down Expand Up @@ -864,15 +860,10 @@ class TupleEdit(Container[ValueWidget]):
----------
value : Iterable, optional
The starting value for the widget.
layout : str, optional
The layout for the container. must be one of ``{'horizontal',
'vertical'}``. by default "horizontal"
nullable : bool
If `True`, the widget will accepts `None` as a valid value, by default `False`.
options: dict, optional
Widget options of child widgets.
**kwargs : Any
All additional keyword arguments are passed to `Container` constructor.
"""

def __init__(
Expand All @@ -885,7 +876,8 @@ def __init__(
) -> None:
self._nullable = nullable
self._args_types: tuple[type, ...] | None = None
container_kwargs["labels"] = False
container_kwargs.setdefault("labels", False)
container_kwargs.setdefault("layout", "horizontal")
super().__init__(**container_kwargs)
self._child_options = options or {}
self.margins = (0, 0, 0, 0)
Expand Down

0 comments on commit 48c94e2

Please sign in to comment.