Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make kwargs of container-like widgets consistent #606

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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