当前位置: 首页>>代码示例>>Python>>正文


Python SimplePanel.getAbsoluteTop方法代码示例

本文整理汇总了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()
开发者ID:anandology,项目名称:pyjamas,代码行数:74,代码来源:timerdemo.py

示例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()
开发者ID:rgeos,项目名称:bingo,代码行数:65,代码来源:bingo.py


注:本文中的pyjamas.ui.SimplePanel.SimplePanel.getAbsoluteTop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。