|
20 | 20 |
|
21 | 21 | import tempfile, atexit, shutil, datetime, numpy as np |
22 | 22 |
|
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 |
42 | 25 |
|
43 | 26 |
|
44 | 27 | # Creating temporary files and registering cleanup functions |
|
50 | 33 | atexit.register(FILE_CSV.close) |
51 | 34 |
|
52 | 35 |
|
53 | | -class TestParameters(DataSet): |
| 36 | +class TestParameters(gdt.DataSet): |
54 | 37 | """ |
55 | 38 | DataSet test |
56 | 39 | The following text is the DataSet 'comment': <br>Plain text or |
57 | 40 | <b>rich text<sup>2</sup></b> are both supported, |
58 | 41 | as well as special characters (α, β, γ, δ, ...) |
59 | 42 | """ |
60 | 43 |
|
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( |
68 | 51 | "Float (with slider)", default=0.5, min=0, max=1, step=0.01, slider=True |
69 | 52 | ) |
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( |
78 | 63 | "Single choice 1", |
79 | 64 | [("16", "first choice"), ("32", "second choice"), ("64", "third choice")], |
80 | 65 | ) |
81 | | - mchoice2 = ImageChoiceItem( |
| 66 | + mchoice2 = gdi.ImageChoiceItem( |
82 | 67 | "Single choice 2", |
83 | 68 | [ |
84 | 69 | ("rect", "first choice", "gif.png"), |
85 | 70 | ("ell", "second choice", "txt.png"), |
86 | 71 | ("qcq", "third choice", "file.png"), |
87 | 72 | ], |
88 | 73 | ) |
89 | | - _eg = EndGroup("A sub group") |
90 | | - floatarray = FloatArrayItem( |
| 74 | + _eg = gdt.EndGroup("A sub group") |
| 75 | + floatarray = gdi.FloatArrayItem( |
91 | 76 | "Float array", default=np.ones((50, 5), float), format=" %.2e " |
92 | 77 | ).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) |
96 | 81 | mchoice1 = ( |
97 | | - MultipleChoiceItem( |
| 82 | + gdi.MultipleChoiceItem( |
98 | 83 | "MC type 2", ["first choice", "second choice", "third choice"] |
99 | 84 | ) |
100 | 85 | .vertical(1) |
|
0 commit comments