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

fix nested functiongui show #175

Merged
merged 2 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions magicgui/widgets/_function_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ class FunctionGui(Container, Generic[_R]):
app : magicgui.Application or str, optional
A backend to use, by default ``None`` (use the default backend.)
visible : bool, optional
Whether to immediately show the widget, by default False
Whether to immediately show the widget. If ``False``, widget is explicitly
hidden. If ``None``, widget is not shown, but will be shown if a parent
container is shown, by default None.
auto_call : bool, optional
If True, changing any parameter in either the GUI or the widget attributes
will call the original function with the current settings. by default False
Expand Down Expand Up @@ -113,7 +115,7 @@ def __init__(
labels: bool = True,
tooltips: bool = True,
app: AppRef = None,
visible: bool = False,
visible: bool = None,
auto_call: bool = False,
result_widget: bool = False,
param_options: dict[str, dict] | None = None,
Expand Down
14 changes: 14 additions & 0 deletions tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,20 @@ def test_range_widget_min():
assert (v.start, v.stop, v.step) == (0, 1000, 5)


def test_containers_show_nested_containers():
"""make sure showing a container shows a nested FunctionGui."""

@magicgui
def func(x: int, y: str):
pass

assert not func.visible
c2 = widgets.Container(widgets=[func])
assert not c2.visible
c2.show()
assert c2.visible and func.visible


def test_file_dialog_events():
"""Test that file dialog events emit the value of the line_edit."""
from pathlib import Path
Expand Down