comparison src/browser/sat_browser/base_widget.py @ 559:77372641e05d

browser_side (plugin OTR): display the correct icons on opening the window + auto-open on accepted invitation
author souliane <souliane@mailoo.org>
date Tue, 23 Sep 2014 13:57:36 +0200
parents d02335553b5d
children b07f0fe2763a
comparison
equal deleted inserted replaced
558:b38629924602 559:77372641e05d
227 227
228 228
229 class LiberviaWidget(DropCell, VerticalPanel, ClickHandler): 229 class LiberviaWidget(DropCell, VerticalPanel, ClickHandler):
230 """Libervia's widget which can replace itself with a dropped widget on DnD""" 230 """Libervia's widget which can replace itself with a dropped widget on DnD"""
231 231
232 def __init__(self, host, title='', info='', selectable=False): 232 def __init__(self, host, title='', info=None, selectable=False):
233 """Init the widget 233 """Init the widget
234 @param host (SatWebFrontend): SatWebFrontend instance 234 @param host (SatWebFrontend): SatWebFrontend instance
235 @param title (str): title shown in the header of the widget 235 @param title (str): title shown in the header of the widget
236 @param info (str): info shown in the header of the widget 236 @param info (str, callable): info shown in the header of the widget
237 @param selectable (bool): True is widget can be selected by user""" 237 @param selectable (bool): True is widget can be selected by user"""
238 VerticalPanel.__init__(self) 238 VerticalPanel.__init__(self)
239 DropCell.__init__(self, host) 239 DropCell.__init__(self, host)
240 ClickHandler.__init__(self) 240 ClickHandler.__init__(self)
241 self.__selectable = selectable 241 self.__selectable = selectable
242 self.__title_id = HTMLPanel.createUniqueId() 242 self.__title_id = HTMLPanel.createUniqueId()
243 self.__setting_button_id = HTMLPanel.createUniqueId() 243 self.__setting_button_id = HTMLPanel.createUniqueId()
244 self.__close_button_id = HTMLPanel.createUniqueId() 244 self.__close_button_id = HTMLPanel.createUniqueId()
245 self.__title = Label(title) 245 self.__title = Label(title)
246 self.__title.setStyleName('widgetHeader_title') 246 self.__title.setStyleName('widgetHeader_title')
247 if info: 247 if info is not None:
248 self.__info = HTML(info) 248 if isinstance(info, str):
249 self.__info = HTML(info)
250 else: # the info will be set by a callback
251 assert(callable(info))
252 self.__info = HTML()
253 info(self.__info.setHTML)
249 self.__info.setStyleName('widgetHeader_info') 254 self.__info.setStyleName('widgetHeader_info')
250 else: 255 else:
251 self.__info = None 256 self.__info = None
252 self._close_listeners = [] 257 self._close_listeners = []
253 header = WidgetHeader(self, host, self.__title, self.__info) 258 header = WidgetHeader(self, host, self.__title, self.__info)
392 def setHeaderInfo(self, text): 397 def setHeaderInfo(self, text):
393 """change the info in the header of the widget 398 """change the info in the header of the widget
394 @param text: text of the new title""" 399 @param text: text of the new title"""
395 try: 400 try:
396 self.__info.setHTML(text) 401 self.__info.setHTML(text)
397 except AttributeError: 402 except TypeError:
398 log.error("LiberviaWidget.setInfo: info widget has not been initialized!") 403 log.error("LiberviaWidget.setInfo: info widget has not been initialized!")
399 404
400 def isSelectable(self): 405 def isSelectable(self):
401 return self.__selectable 406 return self.__selectable
402 407