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 pyjamas.ui.PopupPanel import PopupPanel 6 from pyjamas import Factory 7 from pyjamas.ui.HTML import HTML 8 from pyjamas.ui.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, basestring): 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 timer is tooltip_hide_timer: 53 tooltip_hide_timer = None 54 55 if timer is self.tooltip_show_timer: 56 self.show() 57 else: 58 self.hide()62 DEFAULT_TOOLTIP_STYLE = "TooltipPopup" 63 DEFAULT_OFFSET_X = 10 64 DEFAULT_OFFSET_Y = 35 65115 116 Factory.registerClass('pyjamas.ui.Tooltip', 'Tooltip', Tooltip) 11767 if not styleName: 68 styleName = self.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 = self.DEFAULT_OFFSET_X 76 self.offsetY = self.DEFAULT_OFFSET_Y7779 self.hide() 80 self.tooltip = Tooltip(sender, self.offsetX, self.offsetY, self.text, self.show_delay, self.hide_delay, self.styleName)8183 self.hide()84 87 90 93 96 99 102 105 108 111
Home | Trees | Indices | Help |
|
---|
http://epydoc.sourceforge.net |