diff browser_side/panels.py @ 92:dd54bc13ac81

browser side: widgets' width and height can now be fixed + tarot game position fix
author Goffi <goffi@goffi.org>
date Tue, 28 Jun 2011 03:43:48 +0200
parents 9729ed7171a6
children d7a4bbaddfb0
line wrap: on
line diff
--- a/browser_side/panels.py	Tue Jun 28 02:20:02 2011 +0200
+++ b/browser_side/panels.py	Tue Jun 28 03:43:48 2011 +0200
@@ -183,6 +183,8 @@
         widpanel = self._getWidgetsPanel()
         row, col = widpanel.getIndex(self)
         body = VerticalPanel()
+        
+        #colspan & rowspan
         colspan = widpanel.getColSpan(row, col)
         rowspan = widpanel.getRowSpan(row, col)
         def onColSpanChange(value):
@@ -197,6 +199,43 @@
         rowspan_setter.setWidth('100%')
         body.add(colspan_setter)
         body.add(rowspan_setter)
+        
+        #size
+        width_str = self.getWidth()
+        if width_str.endswith('px'):
+            width=int(width_str[:-2])
+        else:
+            width = 0
+        def onWidthChange(value):
+            if not value:
+                self.setWidth('100%')
+            else:
+                self.setWidth('%dpx' % value)
+        def onHeightChange(value):
+            if not value:
+                self.setHeight('100%')
+            else:
+                self.setHeight('%dpx' % value)
+        width_setter = dialog.IntSetter("width (0=auto)", width)
+        width_setter.addValueChangeListener(onWidthChange)
+        width_setter.setWidth('100%')
+        height_setter = dialog.IntSetter("height (0=auto)", height)
+        height_setter.addValueChangeListener(onHeightChange)
+        height_setter.setHeight('100%')
+        body.add(width_setter)
+        body.add(height_setter)
+
+        #reset
+        def onReset(sender):
+            colspan_setter.setValue(1)
+            rowspan_setter.setValue(1)
+            width_setter.setValue(0)
+            height_setter.setValue(0)
+        
+        reset_bt = Button("Reset", onReset)
+        body.add(reset_bt)
+        body.setCellHorizontalAlignment(reset_bt, HasAlignment.ALIGN_CENTER)
+        
         _dialog = dialog.GenericDialog("Widget setting", body)
         _dialog.show()
 
@@ -663,7 +702,7 @@
         """Configure the chat window to start a game"""
         if game_type=="Tarot":
             self.tarot_panel = CardPanel(self, referee, players, self.nick)
-            self.vpanel.insert(self.tarot_panel, 1)
+            self.vpanel.insert(self.tarot_panel, 0)
             self.vpanel.setCellHeight(self.tarot_panel, self.tarot_panel.getHeight())
     
     def getGame(self, game_type):