-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
33f1e90
commit 7942e75
Showing
35 changed files
with
819 additions
and
865 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Empty file.
120 changes: 60 additions & 60 deletions
120
guidata/tests/test_activable_dataset.py → ...a/tests/dataset/test_activable_dataset.py
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 |
---|---|---|
@@ -1,60 +1,60 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Licensed under the terms of the BSD 3-Clause | ||
# (see guidata/LICENSE for details) | ||
|
||
""" | ||
ActivableDataSet example | ||
Warning: ActivableDataSet objects were made to be integrated inside GUI layouts. | ||
So this example with dialog boxes may be confusing. | ||
--> see tests/editgroupbox.py to understand the activable dataset usage | ||
""" | ||
|
||
# When editing, all items are shown. | ||
# When showing dataset in read-only mode (e.g. inside another layout), all items | ||
# are shown except the enable item. | ||
|
||
import guidata.dataset as gds | ||
from guidata.env import execenv | ||
from guidata.qthelpers import qt_app_context | ||
|
||
# guitest: show | ||
|
||
|
||
class Parameters(gds.ActivableDataSet): | ||
""" | ||
Example | ||
<b>Activable dataset example</b> | ||
""" | ||
|
||
def __init__(self, title=None, comment=None, icon=""): | ||
gds.ActivableDataSet.__init__(self, title, comment, icon) | ||
|
||
enable = gds.BoolItem( | ||
"Enable parameter set", | ||
help="If disabled, the following parameters will be ignored", | ||
default=False, | ||
) | ||
param0 = gds.ChoiceItem("Param 0", ["choice #1", "choice #2", "choice #3"]) | ||
param1 = gds.FloatItem("Param 1", default=0, min=0) | ||
param2 = gds.FloatItem("Param 2", default=0.93) | ||
color = gds.ColorItem("Color", default="red") | ||
|
||
|
||
Parameters.active_setup() | ||
|
||
|
||
def test_activable_dataset(): | ||
"""Test activable dataset""" | ||
with qt_app_context(): | ||
prm = Parameters() | ||
prm.set_writeable() | ||
prm.edit() | ||
prm.set_readonly() | ||
prm.view() | ||
execenv.print("OK") | ||
|
||
|
||
if __name__ == "__main__": | ||
test_activable_dataset() | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Licensed under the terms of the BSD 3-Clause | ||
# (see guidata/LICENSE for details) | ||
|
||
""" | ||
ActivableDataSet example | ||
Warning: ActivableDataSet objects were made to be integrated inside GUI layouts. | ||
So this example with dialog boxes may be confusing. | ||
--> see tests/editgroupbox.py to understand the activable dataset usage | ||
""" | ||
|
||
# When editing, all items are shown. | ||
# When showing dataset in read-only mode (e.g. inside another layout), all items | ||
# are shown except the enable item. | ||
|
||
import guidata.dataset as gds | ||
from guidata.env import execenv | ||
from guidata.qthelpers import qt_app_context | ||
|
||
# guitest: show | ||
|
||
|
||
class Parameters(gds.ActivableDataSet): | ||
""" | ||
Example | ||
<b>Activable dataset example</b> | ||
""" | ||
|
||
def __init__(self, title=None, comment=None, icon=""): | ||
gds.ActivableDataSet.__init__(self, title, comment, icon) | ||
|
||
enable = gds.BoolItem( | ||
"Enable parameter set", | ||
help="If disabled, the following parameters will be ignored", | ||
default=False, | ||
) | ||
param0 = gds.ChoiceItem("Param 0", ["choice #1", "choice #2", "choice #3"]) | ||
param1 = gds.FloatItem("Param 1", default=0, min=0) | ||
param2 = gds.FloatItem("Param 2", default=0.93) | ||
color = gds.ColorItem("Color", default="red") | ||
|
||
|
||
Parameters.active_setup() | ||
|
||
|
||
def test_activable_dataset(): | ||
"""Test activable dataset""" | ||
with qt_app_context(): | ||
prm = Parameters() | ||
prm.set_writeable() | ||
prm.edit() | ||
prm.set_readonly() | ||
prm.view() | ||
execenv.print("OK") | ||
|
||
|
||
if __name__ == "__main__": | ||
test_activable_dataset() |
78 changes: 39 additions & 39 deletions
78
guidata/tests/test_activable_items.py → ...ata/tests/dataset/test_activable_items.py
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 |
---|---|---|
@@ -1,39 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Licensed under the terms of the BSD 3-Clause | ||
# (see guidata/LICENSE for details) | ||
|
||
""" | ||
Example with activable items: items which active state is changed depending | ||
on another item's value. | ||
""" | ||
|
||
# guitest: show | ||
|
||
from guidata.dataset import ChoiceItem, DataSet, FloatItem, FuncProp, GetAttrProp | ||
from guidata.env import execenv | ||
from guidata.qthelpers import qt_app_context | ||
|
||
choices = (("A", "Choice #1: A"), ("B", "Choice #2: B"), ("C", "Choice #3: C")) | ||
|
||
|
||
class Parameters(DataSet): | ||
"""Example dataset""" | ||
|
||
_prop = GetAttrProp("choice") | ||
choice = ChoiceItem("Choice", choices).set_prop("display", store=_prop) | ||
x1 = FloatItem("x1") | ||
x2 = FloatItem("x2").set_prop("display", active=FuncProp(_prop, lambda x: x == "B")) | ||
x3 = FloatItem("x3").set_prop("display", active=FuncProp(_prop, lambda x: x == "C")) | ||
|
||
|
||
def test_activable_items(): | ||
"""Test activable items""" | ||
with qt_app_context(): | ||
test = Parameters() | ||
test.edit() | ||
execenv.print("OK") | ||
|
||
|
||
if __name__ == "__main__": | ||
test_activable_items() | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Licensed under the terms of the BSD 3-Clause | ||
# (see guidata/LICENSE for details) | ||
|
||
""" | ||
Example with activable items: items which active state is changed depending | ||
on another item's value. | ||
""" | ||
|
||
# guitest: show | ||
|
||
from guidata.dataset import ChoiceItem, DataSet, FloatItem, FuncProp, GetAttrProp | ||
from guidata.env import execenv | ||
from guidata.qthelpers import qt_app_context | ||
|
||
choices = (("A", "Choice #1: A"), ("B", "Choice #2: B"), ("C", "Choice #3: C")) | ||
|
||
|
||
class Parameters(DataSet): | ||
"""Example dataset""" | ||
|
||
_prop = GetAttrProp("choice") | ||
choice = ChoiceItem("Choice", choices).set_prop("display", store=_prop) | ||
x1 = FloatItem("x1") | ||
x2 = FloatItem("x2").set_prop("display", active=FuncProp(_prop, lambda x: x == "B")) | ||
x3 = FloatItem("x3").set_prop("display", active=FuncProp(_prop, lambda x: x == "C")) | ||
|
||
|
||
def test_activable_items(): | ||
"""Test activable items""" | ||
with qt_app_context(): | ||
test = Parameters() | ||
test.edit() | ||
execenv.print("OK") | ||
|
||
|
||
if __name__ == "__main__": | ||
test_activable_items() |
Oops, something went wrong.