本文整理汇总了Python中pyjamas.ui.SimplePanel.SimplePanel.getAbsoluteTop方法的典型用法代码示例。如果您正苦于以下问题:Python SimplePanel.getAbsoluteTop方法的具体用法?Python SimplePanel.getAbsoluteTop怎么用?Python SimplePanel.getAbsoluteTop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.SimplePanel.SimplePanel
的用法示例。
在下文中一共展示了SimplePanel.getAbsoluteTop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PopupTimerButton
# 需要导入模块: from pyjamas.ui.SimplePanel import SimplePanel [as 别名]
# 或者: from pyjamas.ui.SimplePanel.SimplePanel import getAbsoluteTop [as 别名]
class PopupTimerButton(Timer, Button):
__doc__ = '''The timer in this demo is a subclass of Timer which
implements the <code>run()</code> method. Worth noting in this
example is the use of the method <code>schedule()</code> at the
end of <code>run()</code> (contrast this to the use of
<code>scheduleRepeating()</code> in the previous example). In this
demo when the timer counts down to zero it creates a popup which
will appear in the box to the left. The timer can be cancelled by
clicking the button before it reaches zero.
'''
def __init__(self, countdown):
# It's a Timer, no it's a Button, WAIT! It's BOTH!!
Timer.__init__(self)
Button.__init__(self)
# save the countdown value
self.countdown_save = countdown
# this instance handles the clicks
self.addClickListener(self)
# the box the popups go into
self.box = SimplePanel(StyleName='popupbox')
# kickstart
self.reset()
def run(self):
# When subclassing, we just implement the run method
# update the countdown
self.setHTML('Popup in <b>%d</b> seconds! (Click to cancel)'
% self.countdown)
# reschdule if we're not to zero else create the popup
self.countdown -= 1
if self.countdown >= 0:
self.schedule(1000)
else:
self.create_popup()
self.reset()
def reset(self):
# reset to starting state
self.setHTML('Click for countdown popup')
self.countdown = self.countdown_save
self.start = True
def onClick(self, *arg):
# handle button clicks
# are we cancelling?
if not self.start:
self.cancel()
self.reset()
return
# no we're starting
self.start = False
self.schedule(1)
def create_popup(self):
# create the popup in the middle box
popup = DialogBox(False, False)
popup.onClick = lambda w: popup.hide()
popup.setHTML('<b>Hello!</b>')
popup.setWidget(Button('Close', popup))
x = self.box.getAbsoluteLeft() + random()*100
y = self.box.getAbsoluteTop() + random()*100
popup.setPopupPosition(x, y)
popup.show()
示例2: PopupTimerButton
# 需要导入模块: from pyjamas.ui.SimplePanel import SimplePanel [as 别名]
# 或者: from pyjamas.ui.SimplePanel.SimplePanel import getAbsoluteTop [as 别名]
class PopupTimerButton(Timer, Button):
def __init__(self, countdown):
# It's a Timer, no it's a Button, WAIT! It's BOTH!!
Timer.__init__(self)
Button.__init__(self)
# save the countdown value
self.countdown_save = countdown
# this instance handles the clicks
self.addClickListener(self)
# the box the popups go into
self.box = SimplePanel(StyleName='popupbox')
# kickstart
self.reset()
def run(self):
# When subclassing, we just implement the run method
# update the countdown
self.setHTML('Popup in <b>%d</b> seconds! (Click to cancel)'
% self.countdown)
# reschdule if we're not to zero else create the popup
self.countdown -= 1
if self.countdown >= 0:
self.schedule(1000)
else:
self.create_popup()
self.reset()
def reset(self):
# reset to starting state
self.setHTML('Click for countdown popup')
self.countdown = self.countdown_save
self.start = True
def onClick(self, *arg):
# handle button clicks
# are we cancelling?
if not self.start:
self.cancel()
self.reset()
return
# no we're starting
self.start = False
self.schedule(1)
def create_popup(self):
# create the popup in the middle box
popup = DialogBox(False, False)
popup.setHTML(num.pop())
x = self.box.getAbsoluteLeft() + random()*100
y = self.box.getAbsoluteTop() + random()*100
popup.setPopupPosition(x, y)
popup.show()