Mercurial > libervia-web
comparison src/browser/sat_browser/base_widget.py @ 596:9054793ab60d frontends_multi_profiles
browser side (base widget): added an iterator on WidgetsPanel to iterate throught contained widgets, fixed widget deletion, commented a base try/catch (without exception specified), should be uncommented once a good Exception is here
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 06 Feb 2015 19:19:49 +0100 |
parents | a099990f77a6 |
children | ed6d8f7c6026 |
comparison
equal
deleted
inserted
replaced
595:d78126d82ca0 | 596:9054793ab60d |
---|---|
166 _new_panel = self.drop_keys[item_type](self.host, item) | 166 _new_panel = self.drop_keys[item_type](self.host, item) |
167 else: | 167 else: |
168 log.warning("unmanaged item type") | 168 log.warning("unmanaged item type") |
169 return | 169 return |
170 if isinstance(self, LiberviaWidget): | 170 if isinstance(self, LiberviaWidget): |
171 self.host.unregisterWidget(self) | 171 # self.host.unregisterWidget(self) # FIXME |
172 self.onQuit() | 172 self.onQuit() |
173 if not isinstance(_new_panel, LiberviaWidget): | 173 if not isinstance(_new_panel, LiberviaWidget): |
174 log.warning("droping an object which is not a class of LiberviaWidget") | 174 log.warning("droping an object which is not a class of LiberviaWidget") |
175 _flextable = self.getParent() | 175 _flextable = self.getParent() |
176 _widgetspanel = _flextable.getParent().getParent() | 176 _widgetspanel = _flextable.getParent().getParent() |
182 _width = 90/float(len(_unempty_panels) or 1) | 182 _width = 90/float(len(_unempty_panels) or 1) |
183 #now we resize all the cell of the column | 183 #now we resize all the cell of the column |
184 for panel in _unempty_panels: | 184 for panel in _unempty_panels: |
185 td_elt = panel.getElement().parentNode | 185 td_elt = panel.getElement().parentNode |
186 DOM.setStyleAttribute(td_elt, "width", "%s%%" % _width)""" | 186 DOM.setStyleAttribute(td_elt, "width", "%s%%" % _width)""" |
187 #FIXME: delete object ? Check the right way with pyjamas | 187 if isinstance(self, quick_widgets.QuickWidget): |
188 self.host.widgets.deleteWidget(self) | |
188 | 189 |
189 | 190 |
190 class WidgetMenuBar(base_menu.GenericMenuBar): | 191 class WidgetMenuBar(base_menu.GenericMenuBar): |
191 | 192 |
192 ITEM_TPL = "<img src='media/icons/misc/%s.png' />" | 193 ITEM_TPL = "<img src='media/icons/misc/%s.png' />" |
572 _bottom = BottomBorderWidget(self.host) | 573 _bottom = BottomBorderWidget(self.host) |
573 self.flextable.setWidget(0, 0, _bottom) # There will be always an Empty widget on the last row, | 574 self.flextable.setWidget(0, 0, _bottom) # There will be always an Empty widget on the last row, |
574 # dropping a widget there will add a new row | 575 # dropping a widget there will add a new row |
575 td_elt = _bottom.getElement().parentNode | 576 td_elt = _bottom.getElement().parentNode |
576 DOM.setStyleAttribute(td_elt, "height", "1px") # needed so the cell adapt to the size of the border (specially in webkit) | 577 DOM.setStyleAttribute(td_elt, "height", "1px") # needed so the cell adapt to the size of the border (specially in webkit) |
577 self._max_cols = 1 # give the maximum number of columns i a raw | 578 self._max_cols = 1 # give the maximum number of columns in a raw |
579 | |
580 @property | |
581 def widgets(self): | |
582 return iter(self.flextable) | |
578 | 583 |
579 def isLocked(self): | 584 def isLocked(self): |
580 return self.locked | 585 return self.locked |
581 | 586 |
582 def changeWidget(self, row, col, wid): | 587 def changeWidget(self, row, col, wid): |
583 """Change the widget in the given location, add row or columns when necessary""" | 588 """Change the widget in the given location, add row or columns when necessary""" |
584 log.debug("changing widget: %s %s %s" % (wid.getDebugName(), row, col)) | 589 log.debug("changing widget: %s %s %s" % (wid.getDebugName(), row, col)) |
585 last_row = max(0, self.flextable.getRowCount() - 1) | 590 last_row = max(0, self.flextable.getRowCount() - 1) |
586 try: | 591 # try: # FIXME: except without exception specified ! |
587 prev_wid = self.flextable.getWidget(row, col) | 592 prev_wid = self.flextable.getWidget(row, col) |
588 except: | 593 # except: |
589 log.error("Trying to change an unexisting widget !") | 594 # log.error("Trying to change an unexisting widget !") |
590 return | 595 # return |
591 | 596 |
592 cellFormatter = self.flextable.getFlexCellFormatter() | 597 cellFormatter = self.flextable.getFlexCellFormatter() |
593 | 598 |
594 if isinstance(prev_wid, BorderWidget): | 599 if isinstance(prev_wid, BorderWidget): |
595 # We are on a border, we must create a row and/or columns | 600 # We are on a border, we must create a row and/or columns |
596 log.debug("BORDER WIDGET") | |
597 prev_wid.removeStyleName('dragover') | 601 prev_wid.removeStyleName('dragover') |
598 | 602 |
599 if isinstance(prev_wid, BottomBorderWidget): | 603 if isinstance(prev_wid, BottomBorderWidget): |
600 # We are on the bottom border, we create a new row | 604 # We are on the bottom border, we create a new row |
601 self.flextable.insertRow(last_row) | 605 self.flextable.insertRow(last_row) |