comparison browser_side/panels.py @ 88:50b480fd0605

browser side: widgetsPanel is now scrollable when there are too many widgets, and widgets have a minimum size
author Goffi <goffi@goffi.org>
date Mon, 27 Jun 2011 16:46:31 +0200
parents 6c3b3254605f
children 8d2c7be09eef
comparison
equal deleted inserted replaced
87:3029e3fdbd40 88:50b480fd0605
112 if isinstance(self, LiberviaWidget): 112 if isinstance(self, LiberviaWidget):
113 self.host.unregisterWidget(self) 113 self.host.unregisterWidget(self)
114 if not isinstance(_new_panel, LiberviaWidget): 114 if not isinstance(_new_panel, LiberviaWidget):
115 print ('WARNING: droping an object which is not a class of LiberviaWidget') 115 print ('WARNING: droping an object which is not a class of LiberviaWidget')
116 _flextable = self.getParent() 116 _flextable = self.getParent()
117 _widgetpanel = _flextable.getParent() 117 _widgetspanel = _flextable.getParent().getParent()
118 row_idx, cell_idx = self._getCellAndRow(_flextable, event) 118 row_idx, cell_idx = self._getCellAndRow(_flextable, event)
119 if self.host.selected == self: 119 if self.host.selected == self:
120 self.host.select(None) 120 self.host.select(None)
121 _widgetpanel.changeWidget(row_idx, cell_idx, _new_panel) 121 _widgetspanel.changeWidget(row_idx, cell_idx, _new_panel)
122 """_unempty_panels = filter(lambda wid:not isinstance(wid,EmptyWidget),list(_flextable)) 122 """_unempty_panels = filter(lambda wid:not isinstance(wid,EmptyWidget),list(_flextable))
123 _width = 90/float(len(_unempty_panels) or 1) 123 _width = 90/float(len(_unempty_panels) or 1)
124 #now we resize all the cell of the column 124 #now we resize all the cell of the column
125 for panel in _unempty_panels: 125 for panel in _unempty_panels:
126 td_elt = panel.getElement().parentNode 126 td_elt = panel.getElement().parentNode
172 def onClick(self, sender): 172 def onClick(self, sender):
173 self.host.select(self) 173 self.host.select(self)
174 174
175 def onClose(self, sender): 175 def onClose(self, sender):
176 print "onClose:", sender 176 print "onClose:", sender
177 _widgetpanel = self.getParent().getParent() 177 _widgetspanel = self.getParent().getParent().getParent()
178 _widgetpanel.removeWidget(self) 178 _widgetspanel.removeWidget(self)
179 179
180 def setTitle(self, text): 180 def setTitle(self, text):
181 """change the title in the header of the widget 181 """change the title in the header of the widget
182 @param text: text of the new title""" 182 @param text: text of the new title"""
183 self.__title.setText(text) 183 self.__title.setText(text)
647 """Return class managing the game type""" 647 """Return class managing the game type"""
648 #TODO: check that the game is launched, and manage errors 648 #TODO: check that the game is launched, and manage errors
649 if game_type=="Tarot": 649 if game_type=="Tarot":
650 return self.tarot_panel 650 return self.tarot_panel
651 651
652 class WidgetsPanel(SimplePanel): 652 class WidgetsPanel(ScrollPanelWrapper):
653 653
654 def __init__(self, host): 654 def __init__(self, host):
655 SimplePanel.__init__(self) 655 ScrollPanelWrapper.__init__(self)
656 self.setSize('100%', '100%')
656 self.host = host 657 self.host = host
657 self.flextable = FlexTable() 658 self.flextable = FlexTable()
658 self.flextable.setSize('100%','100%') 659 self.flextable.setSize('100%','100%')
659 self.add(self.flextable) 660 self.setWidget(self.flextable)
660 self.setStyleName('widgetsPanel') 661 self.setStyleName('widgetsPanel')
661 _bottom = BottomBorderWidget(self.host) 662 _bottom = BottomBorderWidget(self.host)
662 self.flextable.setWidget(0, 0, _bottom) #There will be always an Empty widget on the last row, 663 self.flextable.setWidget(0, 0, _bottom) #There will be always an Empty widget on the last row,
663 #dropping a widget there will add a new row 664 #dropping a widget there will add a new row
664 self._max_cols = 1 #give the maximum number of columns i a raw 665 self._max_cols = 1 #give the maximum number of columns i a raw
670 try: 671 try:
671 prev_wid = self.flextable.getWidget(row, col) 672 prev_wid = self.flextable.getWidget(row, col)
672 except: 673 except:
673 print "ERROR: Trying to change an unexisting widget !" 674 print "ERROR: Trying to change an unexisting widget !"
674 return 675 return
676
675 677
676 cellFormatter = self.flextable.getFlexCellFormatter() 678 cellFormatter = self.flextable.getFlexCellFormatter()
677 679
678 if isinstance(prev_wid, BorderWidget): 680 if isinstance(prev_wid, BorderWidget):
679 #We are on a border, we must create a row and/or columns 681 #We are on a border, we must create a row and/or columns