Home | Trees | Indices | Help |
|
---|
|
1 # Tooltip component for Pyjamas 2 # Ported by Willie Gollino from Tooltip component for GWT - Originally by Alexei Sokolov http://gwt.components.googlepages.com/ 3 # Copyright (C) 2009 Luke Kenneth Casson Leighton <lkcl@lkcl.net> 4 5 from PopupPanel import PopupPanel 6 from pyjamas import Factory 7 from HTML import HTML 8 from RootPanel import RootPanel 9 from pyjamas.Timer import Timer 10 11 tooltip_hide_timer = None 1259 6014 - def __init__(self, sender, offsetX, offsetY, contents, 15 show_delay, hide_delay, styleName, **kwargs):16 """ contents may be a text string or it may be a widget 17 """ 18 PopupPanel.__init__(self, True, **kwargs) 19 self.show_delay = show_delay 20 self.hide_delay = hide_delay 21 22 if isinstance(contents, str): 23 contents = HTML(contents) 24 self.add(contents) 25 26 left = sender.getAbsoluteLeft() + offsetX 27 top = sender.getAbsoluteTop() + offsetY 28 29 self.setPopupPosition(left, top) 30 self.setStyleName(styleName) 31 32 if tooltip_hide_timer: 33 self.tooltip_show_timer = Timer(1, self) 34 else: 35 self.tooltip_show_timer = Timer(self.show_delay, self)3638 global tooltip_hide_timer 39 40 # activate fast tooltips 41 tooltip_hide_timer = Timer(self.hide_delay, self) 42 PopupPanel.show(self)43 4749 global tooltip_hide_timer 50 51 # deactivate fast tooltips on last timer 52 if tooltip_hide_timer and tooltip_id == tooltip_hide_timer.getID(): 53 tooltip_hide_timer = None 54 55 if tooltip_id == self.tooltip_show_timer.getID(): 56 self.show() 57 else: 58 self.hide()62 DEFAULT_TOOLTIP_STYLE = "TooltipPopup" 63 DEFAULT_OFFSET_X = 10 64 DEFAULT_OFFSET_Y = 35 65113 114 Factory.registerClass('pyjamas.ui.Tooltip', Tooltip) 11567 if not styleName: 68 styleName = TooltipListener.DEFAULT_TOOLTIP_STYLE 69 70 self.tooltip = None 71 self.text = text 72 self.styleName = styleName 73 self.show_delay = show_delay 74 self.hide_delay = hide_delay 75 self.offsetX = TooltipListener.DEFAULT_OFFSET_X 76 self.offsetY = TooltipListener.DEFAULT_OFFSET_Y7779 if self.tooltip is not None: 80 self.tooltip.hide() 81 self.tooltip = Tooltip(sender, self.offsetX, self.offsetY, self.text, self.show_delay, self.hide_delay, self.styleName)82 86 89 92 95 98 101 104 107 110
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Jun 16 12:42:30 2010 | http://epydoc.sourceforge.net |