Mercurial > libervia-web
changeset 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 | 5f845345176e |
children | 907a72e79b3e |
files | browser_side/dialog.py browser_side/panels.py |
diffstat | 2 files changed, 46 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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:
--- 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):