1 """Implements abstract editor base classes.
2
3 These abstract base classes provide an abstract layer for editing data in a
4 graphical user interface.
5
6 @todo: Make these into true abstract base classes, and implement and use the
7 get_editor_value and set_editor_value functions in non-abstract derived
8 classes.
9 """
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
49 """The base class for all delegates."""
51 """Return data as a value to initialize an editor with.
52 Override this method.
53
54 :return: A value for the editor.
55 :rtype: any (whatever is appropriate for the particular
56 implementation of the editor)
57 """
58 raise NotImplementedError
59
61 """Set data from the editor value. Override this method.
62
63 :param editorvalue: The value of the editor.
64 :type editorvalue: any (whatever is appropriate for the particular
65 implementation of the editor)
66 """
67 raise NotImplementedError
68
70 """Abstract base class for data that can be edited with a spin box that
71 contains an integer. Override get_editor_minimum and get_editor_maximum to
72 set the minimum and maximum values that the spin box may contain.
73
74 Requirement: get_editor_value must return an ``int``, set_editor_value
75 must take an ``int``.
76 """
79
82
85
88
90 """Abstract base class for data that can be edited with a spin box that
91 contains a float. Override get_editor_decimals to set the number of decimals
92 in the editor display.
93
94 Requirement: get_editor_value must return a ``float``, set_editor_value
95 must take a ``float``.
96 """
97
100
102 """Abstract base class for data that can be edited with a single line
103 editor.
104
105 Requirement: get_editor_value must return a ``str``, set_editor_value
106 must take a ``str``.
107 """
108 pass
109
110 -class EditableTextEdit(EditableLineEdit):
111 """Abstract base class for data that can be edited with a multiline editor.
112
113 Requirement: get_editor_value must return a ``str``, set_editor_value
114 must take a ``str``.
115 """
116 pass
117
119 """Abstract base class for data that can be edited with combo boxes.
120 This can be used for for instance enum types.
121
122 Requirement: get_editor_value must return an ``int``, set_editor_value
123 must take an ``int`` (this integer is the index in the list of keys).
124 """
125
127 """Tuple of strings, each string describing an item."""
128 return ()
129
131 """Class for data that can be edited with a bool combo box.
132
133 Requirement: get_value must return a ``bool``, set_value must take a ``bool``.
134 """
136 return ("False", "True")
137
139 if editorvalue == 0:
140 self.set_value(False)
141 elif editorvalue == 1:
142 self.set_value(True)
143 else:
144 raise ValueError("no value for index %i" % editorvalue)
145
148