Mercurial > libervia-backend
comparison frontends/src/primitivus/xmlui.py @ 687:af0d08a84cc6
primitivus card_game: bug fix and improvement
- changeset 56f8a9c99194 introduced a bug because it connected all the list widgets to the parameter change callback. This is not OK because the Tarot is using a list form that is not a parameter.
- some list processing was raising an error when the data is not initialized
- display the "choose contrat" dialog with valign='top' to allow the user see his hand while taking the decision.
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 28 Oct 2013 19:04:49 +0100 |
parents | 56f8a9c99194 |
children | 93bd868b8fb6 |
comparison
equal
deleted
inserted
replaced
686:ae95b0327412 | 687:af0d08a84cc6 |
---|---|
103 elif type_=="bool": | 103 elif type_=="bool": |
104 ctrl = urwid.CheckBox('', state = value=="true") | 104 ctrl = urwid.CheckBox('', state = value=="true") |
105 self.ctrl_list[name] = ({'type':type_, 'control':ctrl}) | 105 self.ctrl_list[name] = ({'type':type_, 'control':ctrl}) |
106 elif type_=="list": | 106 elif type_=="list": |
107 style=[] if elem.getAttribute("multi")=='yes' else ['single'] | 107 style=[] if elem.getAttribute("multi")=='yes' else ['single'] |
108 ctrl = sat_widgets.List(options=[option.getAttribute("value") for option in elem.getElementsByTagName("option")], style=style, on_change=self.onParamChange) | 108 ctrl = sat_widgets.List(options=[option.getAttribute("value") for option in elem.getElementsByTagName("option")], style=style, on_change=self.onParamChange if self.type == "param" else None) |
109 ctrl.selectValue(elem.getAttribute("value")) | 109 ctrl.selectValue(elem.getAttribute("value")) |
110 self.ctrl_list[name] = ({'type':type_, 'control':ctrl}) | 110 self.ctrl_list[name] = ({'type':type_, 'control':ctrl}) |
111 elif type_=="button": | 111 elif type_=="button": |
112 callback_id = elem.getAttribute("callback_id") | 112 callback_id = elem.getAttribute("callback_id") |
113 ctrl = sat_widgets.CustomButton(value, on_press=self.onButtonPress) | 113 ctrl = sat_widgets.CustomButton(value, on_press=self.onButtonPress) |
208 max_len = max([button.getSize() for button in buttons]) | 208 max_len = max([button.getSize() for button in buttons]) |
209 grid_wid = urwid.GridFlow(buttons,max_len,1,0,'center') | 209 grid_wid = urwid.GridFlow(buttons,max_len,1,0,'center') |
210 ret_wid.addFooter(grid_wid) | 210 ret_wid.addFooter(grid_wid) |
211 return ret_wid | 211 return ret_wid |
212 | 212 |
213 def show(self,show_type = 'popup'): | 213 def show(self, show_type='popup', valign='middle'): |
214 """Show the constructed UI | 214 """Show the constructed UI |
215 @param show_type: how to show the UI: | 215 @param show_type: how to show the UI: |
216 - popup | 216 - popup |
217 - window""" | 217 - window |
218 @param valign: vertical alignment when show_type is 'popup'. | |
219 Ignored when show_type is 'window'. | |
220 """ | |
218 self.__dest = "popup" | 221 self.__dest = "popup" |
219 decorated = sat_widgets.LabelLine(self, sat_widgets.SurroundedText(self.title or '')) | 222 decorated = sat_widgets.LabelLine(self, sat_widgets.SurroundedText(self.title or '')) |
220 if show_type == 'popup': | 223 if show_type == 'popup': |
221 self.host.showPopUp(decorated) | 224 self.host.showPopUp(decorated, valign=valign) |
222 elif show_type == 'window': | 225 elif show_type == 'window': |
223 self.host.addWindow(decorated) | 226 self.host.addWindow(decorated) |
224 else: | 227 else: |
225 error(_('INTERNAL ERROR: Unmanaged show_type (%s)') % show_type) | 228 error(_('INTERNAL ERROR: Unmanaged show_type (%s)') % show_type) |
226 assert(False) | 229 assert(False) |