comparison 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
comparison
equal deleted inserted replaced
804:5174657b3378 805:7c05c39156a2
152 152
153 def _xmluiAppend(self, widget): 153 def _xmluiAppend(self, widget):
154 self.sizer.Add(widget, self._xmlui_proportion, flag=wx.EXPAND) 154 self.sizer.Add(widget, self._xmlui_proportion, flag=wx.EXPAND)
155 155
156 156
157 class AdvancedListContainer(WixContainer, xmlui.AdvancedListContainer, wx.Panel): 157 class AdvancedListContainer(WixContainer, xmlui.AdvancedListContainer, wx.ScrolledWindow):
158 158
159 def __init__(self, parent, columns): 159 def __init__(self, parent, columns, selectable='no'):
160 wx.Panel.__init__(self, parent) 160 wx.ScrolledWindow.__init__(self, parent)
161 self._xmlui_selectable = selectable != 'no'
162 if selectable:
163 columns += 1
161 self.sizer = wx.FlexGridSizer(cols=columns) 164 self.sizer = wx.FlexGridSizer(cols=columns)
162 self.SetSizer(self.sizer) 165 self.SetSizer(self.sizer)
163 166 self._xmlui_select_cb = None
164 def _xmluiAddRow(self): 167 self._xmlui_select_idx = None
165 pass 168 self._xmlui_select_widgets = []
166 169
170 def _xmluiAddRow(self, idx):
171 # XXX: select_button is a Q&D way to implement row selection
172 # FIXME: must be done properly
173 if not self._xmlui_selectable:
174 return
175 select_button = wx.Button(self, wx.ID_OK, label=_("select"))
176 self.sizer.Add(select_button)
177 def click_cb(event, idx=idx):
178 cb = self._xmlui_select_cb
179 self._xmlui_select_idx = idx
180 # TODO: fill self._xmlui_select_widgets
181 if cb is not None:
182 cb(self)
183 event.Skip()
184 self.Bind(wx.EVT_BUTTON, click_cb)
185
186 def _xmluiGetSelectedWidgets(self):
187 return self._xmlui_select_widgets
188
189 def _xmluiGetSelectedIndex(self):
190 return self._xmlui_select_idx
191
192 def _xmluiOnSelect(self, callback):
193 self._xmlui_select_cb = callback
167 194
168 class PairsContainer(WixContainer, xmlui.PairsContainer, wx.Panel): 195 class PairsContainer(WixContainer, xmlui.PairsContainer, wx.Panel):
169 196
170 def __init__(self, parent): 197 def __init__(self, parent):
171 wx.Panel.__init__(self, parent) 198 wx.Panel.__init__(self, parent)