1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 """Defines a simple drop-down select."""
17
18 from muntjac.ui.abstract_select import AbstractSelect
19 from muntjac.data.container import IContainer
20
21
23 """This is a simple drop-down select without, for instance, support
24 for multiselect, new items, lazyloading, and other advanced features.
25 Sometimes "native" select without all the bells-and-whistles of the
26 ComboBox is a better choice.
27 """
28
29 CLIENT_WIDGET = None
30
32
33 self._columns = 0
34
35 args = args
36 nargs = len(args)
37 if nargs == 0:
38 super(NativeSelect, self).__init__()
39 elif nargs == 1:
40 caption, = args
41 super(NativeSelect, self).__init__(caption)
42 elif nargs == 2:
43 if isinstance(args[1], IContainer):
44 caption, dataSource = args
45 super(NativeSelect, self).__init__(caption, dataSource)
46 else:
47 caption, options = args
48 super(NativeSelect, self).__init__(caption, options)
49 else:
50 raise ValueError, 'too many arguments'
51
52
54 """Sets the number of columns in the editor. If the number of columns
55 is set 0, the actual number of displayed columns is determined
56 implicitly by the adapter.
57
58 @param columns:
59 the number of columns to set.
60 """
61 if columns < 0:
62 columns = 0
63
64 if self._columns != columns:
65 self._columns = columns
66 self.requestRepaint()
67
68
71
72
73 - def paintContent(self, target):
74 target.addAttribute('type', 'native')
75
76 if self._columns != 0:
77 target.addAttribute('cols', self._columns)
78
79 super(NativeSelect, self).paintContent(target)
80
81
83 if multiSelect == True:
84 raise NotImplementedError, 'Multiselect not supported'
85
86
88 if allowNewOptions == True:
89 raise NotImplementedError, 'newItemsAllowed not supported'
90