Skip to content

Commit b01e19f

Browse files
committed
Fixed missing import for DictItem callback
1 parent 20dc129 commit b01e19f

File tree

2 files changed

+29
-42
lines changed

2 files changed

+29
-42
lines changed

guidata/dataset/dataitems.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,8 @@ class DictItem(ButtonItem):
753753

754754
def __init__(self, label, default=None, help="", check=True):
755755
def dictedit(instance, item, value, parent):
756+
from guidata.widgets.collectionseditor import CollectionsEditor
757+
756758
editor = CollectionsEditor(parent)
757759
value_was_none = value is None
758760
if value_was_none:

guidata/tests/all_items.py

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,8 @@
2020

2121
import tempfile, atexit, shutil, datetime, numpy as np
2222

23-
from guidata.dataset.datatypes import DataSet, BeginGroup, EndGroup
24-
from guidata.dataset.dataitems import (
25-
FloatItem,
26-
IntItem,
27-
BoolItem,
28-
ChoiceItem,
29-
MultipleChoiceItem,
30-
ImageChoiceItem,
31-
FilesOpenItem,
32-
StringItem,
33-
TextItem,
34-
ColorItem,
35-
FileSaveItem,
36-
FileOpenItem,
37-
DirectoryItem,
38-
FloatArrayItem,
39-
DateItem,
40-
DateTimeItem,
41-
)
23+
import guidata.dataset.datatypes as gdt
24+
import guidata.dataset.dataitems as gdi
4225

4326

4427
# Creating temporary files and registering cleanup functions
@@ -50,51 +33,53 @@
5033
atexit.register(FILE_CSV.close)
5134

5235

53-
class TestParameters(DataSet):
36+
class TestParameters(gdt.DataSet):
5437
"""
5538
DataSet test
5639
The following text is the DataSet 'comment': <br>Plain text or
5740
<b>rich text<sup>2</sup></b> are both supported,
5841
as well as special characters (α, β, γ, δ, ...)
5942
"""
6043

61-
dir = DirectoryItem("Directory", TEMPDIR)
62-
fname = FileOpenItem("Open file", ("csv", "eta"), FILE_CSV.name)
63-
fnames = FilesOpenItem("Open files", "csv", FILE_CSV.name)
64-
fname_s = FileSaveItem("Save file", "eta", FILE_ETA.name)
65-
string = StringItem("String")
66-
text = TextItem("Text")
67-
float_slider = FloatItem(
44+
dir = gdi.DirectoryItem("Directory", TEMPDIR)
45+
fname = gdi.FileOpenItem("Open file", ("csv", "eta"), FILE_CSV.name)
46+
fnames = gdi.FilesOpenItem("Open files", "csv", FILE_CSV.name)
47+
fname_s = gdi.FileSaveItem("Save file", "eta", FILE_ETA.name)
48+
string = gdi.StringItem("String")
49+
text = gdi.TextItem("Text")
50+
float_slider = gdi.FloatItem(
6851
"Float (with slider)", default=0.5, min=0, max=1, step=0.01, slider=True
6952
)
70-
integer = IntItem("Integer", default=5, min=3, max=16, slider=True).set_pos(col=1)
71-
dtime = DateTimeItem("Date/time", default=datetime.datetime(2010, 10, 10))
72-
date = DateItem("Date", default=datetime.date(2010, 10, 10)).set_pos(col=1)
73-
bool1 = BoolItem("Boolean option without label")
74-
bool2 = BoolItem("Boolean option with label", "Label")
75-
_bg = BeginGroup("A sub group")
76-
color = ColorItem("Color", default="red")
77-
choice = ChoiceItem(
53+
integer = gdi.IntItem("Integer", default=5, min=3, max=16, slider=True).set_pos(
54+
col=1
55+
)
56+
dtime = gdi.DateTimeItem("Date/time", default=datetime.datetime(2010, 10, 10))
57+
date = gdi.DateItem("Date", default=datetime.date(2010, 10, 10)).set_pos(col=1)
58+
bool1 = gdi.BoolItem("Boolean option without label")
59+
bool2 = gdi.BoolItem("Boolean option with label", "Label")
60+
_bg = gdt.BeginGroup("A sub group")
61+
color = gdi.ColorItem("Color", default="red")
62+
choice = gdi.ChoiceItem(
7863
"Single choice 1",
7964
[("16", "first choice"), ("32", "second choice"), ("64", "third choice")],
8065
)
81-
mchoice2 = ImageChoiceItem(
66+
mchoice2 = gdi.ImageChoiceItem(
8267
"Single choice 2",
8368
[
8469
("rect", "first choice", "gif.png"),
8570
("ell", "second choice", "txt.png"),
8671
("qcq", "third choice", "file.png"),
8772
],
8873
)
89-
_eg = EndGroup("A sub group")
90-
floatarray = FloatArrayItem(
74+
_eg = gdt.EndGroup("A sub group")
75+
floatarray = gdi.FloatArrayItem(
9176
"Float array", default=np.ones((50, 5), float), format=" %.2e "
9277
).set_pos(col=1)
93-
mchoice3 = MultipleChoiceItem("MC type 1", [str(i) for i in range(12)]).horizontal(
94-
4
95-
)
78+
mchoice3 = gdi.MultipleChoiceItem(
79+
"MC type 1", [str(i) for i in range(12)]
80+
).horizontal(4)
9681
mchoice1 = (
97-
MultipleChoiceItem(
82+
gdi.MultipleChoiceItem(
9883
"MC type 2", ["first choice", "second choice", "third choice"]
9984
)
10085
.vertical(1)

0 commit comments

Comments
 (0)