diff 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
line wrap: on
line diff
--- a/frontends/src/primitivus/xmlui.py	Mon Oct 28 18:49:01 2013 +0100
+++ b/frontends/src/primitivus/xmlui.py	Mon Oct 28 19:04:49 2013 +0100
@@ -105,7 +105,7 @@
                 self.ctrl_list[name] = ({'type':type_, 'control':ctrl})
             elif type_=="list":
                 style=[] if elem.getAttribute("multi")=='yes' else ['single']
-                ctrl = sat_widgets.List(options=[option.getAttribute("value") for option in elem.getElementsByTagName("option")], style=style, on_change=self.onParamChange)
+                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)
                 ctrl.selectValue(elem.getAttribute("value"))
                 self.ctrl_list[name] = ({'type':type_, 'control':ctrl})
             elif type_=="button":
@@ -210,15 +210,18 @@
             ret_wid.addFooter(grid_wid)
         return ret_wid
 
-    def show(self,show_type = 'popup'):
+    def show(self, show_type='popup', valign='middle'):
         """Show the constructed UI
         @param show_type: how to show the UI:
             - popup
-            - window"""
+            - window
+        @param valign: vertical alignment when show_type is 'popup'.
+                       Ignored when show_type is 'window'.
+        """
         self.__dest = "popup"
         decorated = sat_widgets.LabelLine(self, sat_widgets.SurroundedText(self.title or ''))
         if show_type == 'popup':
-            self.host.showPopUp(decorated)
+            self.host.showPopUp(decorated, valign=valign)
         elif show_type == 'window':
             self.host.addWindow(decorated)
         else: