comparison frontends/primitivus/xmlui.py @ 167:6fd053c99421

Primitivus: misc improvments on TabsContainer/FocusFrame - FocusFrame: better management of keypress - TabsContainer: new addFooter method, to add a widget on the bottom of the container
author Goffi <goffi@goffi.org>
date Mon, 09 Aug 2010 21:58:28 +0800
parents b318d2b58887
children 2ea8dab08160
comparison
equal deleted inserted replaced
166:b318d2b58887 167:6fd053c99421
162 self.__parseChilds(ret_wid.body, cat_dom.documentElement) 162 self.__parseChilds(ret_wid.body, cat_dom.documentElement)
163 163
164 assert ret_wid.body 164 assert ret_wid.body
165 165
166 if isinstance(ret_wid.body[0],custom_widgets.TabsContainer): 166 if isinstance(ret_wid.body[0],custom_widgets.TabsContainer):
167 ret_wid = urwid.Pile([ret_wid.body[0]]) #xxx: awfull hack cause TabsContainer is a BoxWidget, can't be inside a ListBox 167 ret_wid = ret_wid.body[0] #xxx: awfull hack cause TabsContainer is a BoxWidget, can't be inside a ListBox
168 168
169 169
170 if self.type == 'form': 170 if self.type == 'form':
171 buttons = [] 171 buttons = []
172 buttons.append(urwid.Button(_('Submit'),self.onFormSubmitted)) 172 buttons.append(urwid.Button(_('Submit'),self.onFormSubmitted))
174 buttons.append(urwid.Button(_('Cancel'),self.onFormCancelled)) 174 buttons.append(urwid.Button(_('Cancel'),self.onFormCancelled))
175 max_len = max([len(button.get_label()) for button in buttons]) 175 max_len = max([len(button.get_label()) for button in buttons])
176 grid_wid = urwid.GridFlow(buttons,max_len+4,1,0,'center') 176 grid_wid = urwid.GridFlow(buttons,max_len+4,1,0,'center')
177 ret_wid.body.append(grid_wid) 177 ret_wid.body.append(grid_wid)
178 elif self.type == 'param': 178 elif self.type == 'param':
179 assert(isinstance(ret_wid,urwid.Pile)) 179 assert(isinstance(ret_wid,custom_widgets.TabsContainer))
180 buttons = [] 180 buttons = []
181 buttons.append(custom_widgets.CustomButton(_('Save'),self.onSaveParams)) 181 buttons.append(custom_widgets.CustomButton(_('Save'),self.onSaveParams))
182 buttons.append(custom_widgets.CustomButton(_('Cancel'),lambda x:self.host.removeWindow())) 182 buttons.append(custom_widgets.CustomButton(_('Cancel'),lambda x:self.host.removeWindow()))
183 max_len = max([button.getSize() for button in buttons]) 183 max_len = max([button.getSize() for button in buttons])
184 grid_wid = urwid.GridFlow(buttons,max_len,1,0,'center') 184 grid_wid = urwid.GridFlow(buttons,max_len,1,0,'center')
185 ret_wid.widget_list.append(urwid.Filler(grid_wid)) 185 ret_wid.addFooter(grid_wid)
186 ret_wid.item_types.append(('weight',1))
187
188 return ret_wid 186 return ret_wid
189 187
190 def show(self): 188 def show(self):
191 """Show the constructed UI""" 189 """Show the constructed UI"""
192 decorated = custom_widgets.LabelLine(self, custom_widgets.SurroundedText(self.title or '')) 190 decorated = custom_widgets.LabelLine(self, custom_widgets.SurroundedText(self.title or ''))