-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mandatory
attrib. for ToggleButtons and typing.
- Loading branch information
1 parent
6bdd2bf
commit 944d7ca
Showing
2 changed files
with
120 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from typing import Optional | ||
|
||
import solara | ||
|
||
|
||
def test_toggle_buttons_single(): | ||
value: Optional[str] = None | ||
|
||
def set(value_): | ||
nonlocal value | ||
value = value_ | ||
|
||
@solara.component | ||
def Test(): | ||
with solara.ToggleButtonsSingle("noot", on_value=set) as main: | ||
solara.Button("Aap", value="aap") | ||
solara.Button("Noot", value="noot") | ||
solara.Button("Mies", value="mies") | ||
return main | ||
|
||
group, rc = solara.render_fixed(Test()) | ||
assert group.v_model == 1 | ||
group.v_model = 2 | ||
assert value == "mies" | ||
|
||
|
||
def test_toggle_buttons_multiple(): | ||
value: Optional[str] = None | ||
|
||
def set(value_): | ||
nonlocal value | ||
value = value_ | ||
|
||
@solara.component | ||
def Test(): | ||
with solara.ToggleButtonsMultiple(["noot"], on_value=set) as main: | ||
solara.Button("Aap", value="aap") | ||
solara.Button("Noot", value="noot") | ||
solara.Button("Mies", value="mies") | ||
return main | ||
|
||
group, rc = solara.render_fixed(Test()) | ||
assert group.v_model == [1] | ||
group.v_model = [0, 2] | ||
assert value is not None | ||
assert value == ["aap", "mies"] |