comparison 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
comparison
equal deleted inserted replaced
91:5f845345176e 92:dd54bc13ac81
181 181
182 def onSetting(self, sender): 182 def onSetting(self, sender):
183 widpanel = self._getWidgetsPanel() 183 widpanel = self._getWidgetsPanel()
184 row, col = widpanel.getIndex(self) 184 row, col = widpanel.getIndex(self)
185 body = VerticalPanel() 185 body = VerticalPanel()
186
187 #colspan & rowspan
186 colspan = widpanel.getColSpan(row, col) 188 colspan = widpanel.getColSpan(row, col)
187 rowspan = widpanel.getRowSpan(row, col) 189 rowspan = widpanel.getRowSpan(row, col)
188 def onColSpanChange(value): 190 def onColSpanChange(value):
189 widpanel.setColSpan(row, col, value) 191 widpanel.setColSpan(row, col, value)
190 def onRowSpanChange(value): 192 def onRowSpanChange(value):
195 rowspan_setter = dialog.IntSetter("Rows span", rowspan) 197 rowspan_setter = dialog.IntSetter("Rows span", rowspan)
196 rowspan_setter.addValueChangeListener(onRowSpanChange) 198 rowspan_setter.addValueChangeListener(onRowSpanChange)
197 rowspan_setter.setWidth('100%') 199 rowspan_setter.setWidth('100%')
198 body.add(colspan_setter) 200 body.add(colspan_setter)
199 body.add(rowspan_setter) 201 body.add(rowspan_setter)
202
203 #size
204 width_str = self.getWidth()
205 if width_str.endswith('px'):
206 width=int(width_str[:-2])
207 else:
208 width = 0
209 def onWidthChange(value):
210 if not value:
211 self.setWidth('100%')
212 else:
213 self.setWidth('%dpx' % value)
214 def onHeightChange(value):
215 if not value:
216 self.setHeight('100%')
217 else:
218 self.setHeight('%dpx' % value)
219 width_setter = dialog.IntSetter("width (0=auto)", width)
220 width_setter.addValueChangeListener(onWidthChange)
221 width_setter.setWidth('100%')
222 height_setter = dialog.IntSetter("height (0=auto)", height)
223 height_setter.addValueChangeListener(onHeightChange)
224 height_setter.setHeight('100%')
225 body.add(width_setter)
226 body.add(height_setter)
227
228 #reset
229 def onReset(sender):
230 colspan_setter.setValue(1)
231 rowspan_setter.setValue(1)
232 width_setter.setValue(0)
233 height_setter.setValue(0)
234
235 reset_bt = Button("Reset", onReset)
236 body.add(reset_bt)
237 body.setCellHorizontalAlignment(reset_bt, HasAlignment.ALIGN_CENTER)
238
200 _dialog = dialog.GenericDialog("Widget setting", body) 239 _dialog = dialog.GenericDialog("Widget setting", body)
201 _dialog.show() 240 _dialog.show()
202 241
203 def setTitle(self, text): 242 def setTitle(self, text):
204 """change the title in the header of the widget 243 """change the title in the header of the widget
661 700
662 def startGame(self, game_type, referee, players): 701 def startGame(self, game_type, referee, players):
663 """Configure the chat window to start a game""" 702 """Configure the chat window to start a game"""
664 if game_type=="Tarot": 703 if game_type=="Tarot":
665 self.tarot_panel = CardPanel(self, referee, players, self.nick) 704 self.tarot_panel = CardPanel(self, referee, players, self.nick)
666 self.vpanel.insert(self.tarot_panel, 1) 705 self.vpanel.insert(self.tarot_panel, 0)
667 self.vpanel.setCellHeight(self.tarot_panel, self.tarot_panel.getHeight()) 706 self.vpanel.setCellHeight(self.tarot_panel, self.tarot_panel.getHeight())
668 707
669 def getGame(self, game_type): 708 def getGame(self, game_type):
670 """Return class managing the game type""" 709 """Return class managing the game type"""
671 #TODO: check that the game is launched, and manage errors 710 #TODO: check that the game is launched, and manage errors