Mercurial > libervia-backend
comparison frontends/src/primitivus/xmlui.py @ 805:7c05c39156a2
core (XMLUI), frontends: advancedListContainer part 2:
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 04 Feb 2014 18:21:51 +0100 |
parents | 5174657b3378 |
children | 1fe00f0c9a91 |
comparison
equal
deleted
inserted
replaced
804:5174657b3378 | 805:7c05c39156a2 |
---|---|
26 | 26 |
27 | 27 |
28 class PrimitivusEvents(object): | 28 class PrimitivusEvents(object): |
29 """ Used to manage change event of Primitivus widgets """ | 29 """ Used to manage change event of Primitivus widgets """ |
30 | 30 |
31 def _change_callback(self, ctrl, *args, **kwargs): | 31 def _event_callback(self, ctrl, *args, **ktkwargs): |
32 """" Call xmlui callback and ignore any extra argument """ | 32 """" Call xmlui callback and ignore any extra argument """ |
33 args[-1](ctrl) | 33 args[-1](ctrl) |
34 | 34 |
35 def _xmluiOnChange(self, callback): | 35 def _xmluiOnChange(self, callback): |
36 """ Call callback with widget as only argument """ | 36 """ Call callback with widget as only argument """ |
37 urwid.connect_signal(self, 'change', self._change_callback, callback) | 37 urwid.connect_signal(self, 'change', self._event_callback, callback) |
38 | 38 |
39 | 39 |
40 class PrimitivusEmptyWidget(xmlui.EmptyWidget, urwid.Text): | 40 class PrimitivusEmptyWidget(xmlui.EmptyWidget, urwid.Text): |
41 | 41 |
42 def __init__(self, parent): | 42 def __init__(self, parent): |
130 | 130 |
131 def _xmluiGetSelectedValues(self): | 131 def _xmluiGetSelectedValues(self): |
132 return [option.value for option in self.getSelectedValues()] | 132 return [option.value for option in self.getSelectedValues()] |
133 | 133 |
134 | 134 |
135 class PrimitivusAdvancedListContainer(xmlui.AdvancedListContainer, sat_widgets.TableContainer): | 135 class PrimitivusAdvancedListContainer(xmlui.AdvancedListContainer, sat_widgets.TableContainer, PrimitivusEvents): |
136 | 136 |
137 def __init__(self, parent, columns): | 137 def __init__(self, parent, columns, selectable='no'): |
138 options = {'ADAPT':(), 'HIGHLIGHT':()} | 138 options = {'ADAPT':()} |
139 sat_widgets.TableContainer.__init__(self, columns=columns, options=options) | 139 if selectable != 'no': |
140 options['HIGHLIGHT'] = () | |
141 sat_widgets.TableContainer.__init__(self, columns=columns, options=options, row_selectable = selectable!='no') | |
140 | 142 |
141 def _xmluiAppend(self, widget): | 143 def _xmluiAppend(self, widget): |
142 self.addWidget(widget) | 144 self.addWidget(widget) |
143 | 145 |
144 def _xmluiAddRow(self): | 146 def _xmluiAddRow(self, idx): |
145 pass | 147 self.setRowIndex(idx) |
148 | |
149 def _xmluiGetSelectedWidgets(self): | |
150 return self.getSelectedWidgets() | |
151 | |
152 def _xmluiGetSelectedIndex(self): | |
153 return self.getSelectedIndex() | |
154 | |
155 def _xmluiOnSelect(self, callback): | |
156 """ Call callback with widget as only argument """ | |
157 urwid.connect_signal(self, 'click', self._event_callback, callback) | |
146 | 158 |
147 class PrimitivusPairsContainer(xmlui.PairsContainer, sat_widgets.TableContainer): | 159 class PrimitivusPairsContainer(xmlui.PairsContainer, sat_widgets.TableContainer): |
148 | 160 |
149 def __init__(self, parent): | 161 def __init__(self, parent): |
150 options = {'ADAPT':(0,), 'HIGHLIGHT':(0,)} | 162 options = {'ADAPT':(0,), 'HIGHLIGHT':(0,)} |