Mercurial > libervia-backend
diff frontends/src/wix/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/wix/xmlui.py Tue Feb 04 18:19:32 2014 +0100 +++ b/frontends/src/wix/xmlui.py Tue Feb 04 18:21:51 2014 +0100 @@ -154,16 +154,43 @@ self.sizer.Add(widget, self._xmlui_proportion, flag=wx.EXPAND) -class AdvancedListContainer(WixContainer, xmlui.AdvancedListContainer, wx.Panel): +class AdvancedListContainer(WixContainer, xmlui.AdvancedListContainer, wx.ScrolledWindow): - def __init__(self, parent, columns): - wx.Panel.__init__(self, parent) + def __init__(self, parent, columns, selectable='no'): + wx.ScrolledWindow.__init__(self, parent) + self._xmlui_selectable = selectable != 'no' + if selectable: + columns += 1 self.sizer = wx.FlexGridSizer(cols=columns) self.SetSizer(self.sizer) + self._xmlui_select_cb = None + self._xmlui_select_idx = None + self._xmlui_select_widgets = [] - def _xmluiAddRow(self): - pass + def _xmluiAddRow(self, idx): + # XXX: select_button is a Q&D way to implement row selection + # FIXME: must be done properly + if not self._xmlui_selectable: + return + select_button = wx.Button(self, wx.ID_OK, label=_("select")) + self.sizer.Add(select_button) + def click_cb(event, idx=idx): + cb = self._xmlui_select_cb + self._xmlui_select_idx = idx + # TODO: fill self._xmlui_select_widgets + if cb is not None: + cb(self) + event.Skip() + self.Bind(wx.EVT_BUTTON, click_cb) + def _xmluiGetSelectedWidgets(self): + return self._xmlui_select_widgets + + def _xmluiGetSelectedIndex(self): + return self._xmlui_select_idx + + def _xmluiOnSelect(self, callback): + self._xmlui_select_cb = callback class PairsContainer(WixContainer, xmlui.PairsContainer, wx.Panel):