Mercurial > libervia-backend
diff 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 |
line wrap: on
line diff
--- a/frontends/src/primitivus/xmlui.py Tue Feb 04 18:19:32 2014 +0100 +++ b/frontends/src/primitivus/xmlui.py Tue Feb 04 18:21:51 2014 +0100 @@ -28,13 +28,13 @@ class PrimitivusEvents(object): """ Used to manage change event of Primitivus widgets """ - def _change_callback(self, ctrl, *args, **kwargs): + def _event_callback(self, ctrl, *args, **ktkwargs): """" Call xmlui callback and ignore any extra argument """ args[-1](ctrl) def _xmluiOnChange(self, callback): """ Call callback with widget as only argument """ - urwid.connect_signal(self, 'change', self._change_callback, callback) + urwid.connect_signal(self, 'change', self._event_callback, callback) class PrimitivusEmptyWidget(xmlui.EmptyWidget, urwid.Text): @@ -132,17 +132,29 @@ return [option.value for option in self.getSelectedValues()] -class PrimitivusAdvancedListContainer(xmlui.AdvancedListContainer, sat_widgets.TableContainer): +class PrimitivusAdvancedListContainer(xmlui.AdvancedListContainer, sat_widgets.TableContainer, PrimitivusEvents): - def __init__(self, parent, columns): - options = {'ADAPT':(), 'HIGHLIGHT':()} - sat_widgets.TableContainer.__init__(self, columns=columns, options=options) + def __init__(self, parent, columns, selectable='no'): + options = {'ADAPT':()} + if selectable != 'no': + options['HIGHLIGHT'] = () + sat_widgets.TableContainer.__init__(self, columns=columns, options=options, row_selectable = selectable!='no') def _xmluiAppend(self, widget): self.addWidget(widget) - def _xmluiAddRow(self): - pass + def _xmluiAddRow(self, idx): + self.setRowIndex(idx) + + def _xmluiGetSelectedWidgets(self): + return self.getSelectedWidgets() + + def _xmluiGetSelectedIndex(self): + return self.getSelectedIndex() + + def _xmluiOnSelect(self, callback): + """ Call callback with widget as only argument """ + urwid.connect_signal(self, 'click', self._event_callback, callback) class PrimitivusPairsContainer(xmlui.PairsContainer, sat_widgets.TableContainer):