# HG changeset patch # User Goffi # Date 1309225428 -7200 # Node ID dd54bc13ac818b21c842c6bd2192cbba1c090e26 # Parent 5f845345176e351ce034c3593a7ef554fb75aa9d browser side: widgets' width and height can now be fixed + tarot game position fix diff -r 5f845345176e -r dd54bc13ac81 browser_side/dialog.py --- a/browser_side/dialog.py Tue Jun 28 02:20:02 2011 +0200 +++ b/browser_side/dialog.py Tue Jun 28 03:43:48 2011 +0200 @@ -285,6 +285,11 @@ def _callListeners(self): for listener in self.valueChangedListener: listener(self.value) + + def setValue(self, value): + """Change the value and fire valueChange listeners""" + self.value = value + self._callListeners() def onMinus(self, sender): self.value=max(0,self.value-1) @@ -301,7 +306,7 @@ def onInput(self, sender): """Accept only valid integer && normalize print (no leading 0)""" try: - self.value = int(self.box.getText()) + self.value = int(self.box.getText()) if self.bot.getText() else 0 except ValueError: pass if self.value_max: diff -r 5f845345176e -r dd54bc13ac81 browser_side/panels.py --- 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):