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


Python Timer.idle方法代码示例

本文整理汇总了Python中timer.Timer.idle方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.idle方法的具体用法?Python Timer.idle怎么用?Python Timer.idle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在timer.Timer的用法示例。


在下文中一共展示了Timer.idle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: painter_test2

# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import idle [as 别名]
 def painter_test2(n, lines, columns, fps = 25000):
     # test main-thread execution (previewer run as main thread): 
     preview = Preview(title = "Main-thread test without diagram", 
                       lines = lines, columns = columns, fps_limit = fps,
                       painter_class = TestPainter)
     timer = Timer(0.1)
     preview.interactive(True)
     preview.start()
     step = 0
     # create tests in different threads
     while True:
         step += 1
         preview.set_title("Test #" + str(step) + " ADD-del inverse order")
         painters = []
         for i in xrange(0,n):
             painters.append(preview.add_view(i))
             while timer.idle(): 
                 if not preview.step():
                     return
         preview.set_title("Test #" + str(step) + " add-DEL inverse order")
         while len(painters) > 0:
             preview.del_view(painters.pop())
             while timer.idle(): 
                 if not preview.step():
                     return
         preview.set_title("Test #" + str(step) + " ADD-del direct order")
         painters = []
         for i in xrange(0,n):
             painters.append(preview.add_view(i))
             while timer.idle(): 
                 if not preview.step():
                     return
         preview.set_title("Test #" + str(step) + " add-DEL direct order")
         for i in xrange(0,n):
             preview.del_view(painters[i])
             while timer.idle(): 
                 if not preview.step():
                     return
         preview.set_title("Test #" + str(step) + " ADD-del random order")
         painters = []
         for i in xrange(0,n):
             painters.append(preview.add_view(i))
             while timer.idle(): 
                 if not preview.step():
                     return
         preview.set_title("Test #" + str(step) + " add-DEL random order")
         while len(painters) > 0:
             i = random.randint(0, len(painters) - 1)
             preview.del_view(painters[i])
             del painters[i]
             while timer.idle(): 
                 if not preview.step():
                     return
开发者ID:pantuza,项目名称:distributed-voronoi,代码行数:55,代码来源:preview_test.py

示例2: Preview

# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import idle [as 别名]

#.........这里部分代码省略.........
        pygame.display.set_caption(title)
    
    def add_view(self, view, label='', painter_class = None):
        '''
        Include a diagram in previewer
        '''
        assert view is not None
        with self.lock:
            # prevent drawing duplication of same object 
            if view in self.views:
                return False
            # create a painter to object
            if painter_class is None:
                painter = self.default_painter_class(self.count_painters, 
                                                     view, label)
            else:
                painter = painter_class(self.count_painters, view, label)
            self.count_painters += 1
            # make control 
            self.grid.add_painter(painter)
            self.views[view] = painter
            return view
        
    def del_view(self, view):
        assert view is not None
        with self.lock:
            if view in self.views:
                painter = self.views[view]
                self.grid.del_painter(painter)
                del self.views[view]

    def pause(self, delay = 0.0):
        '''
        Defines a idle time to previewer
        '''
        self.frame_timer.pause(delay)

    def stop(self):
        '''
        Request the termination of panel
        '''
        self.state = Preview.KILLED

    def is_running(self):
        '''
        Verify if previewer state is RUNNING
        '''
        return self.state == Preview.RUNNING

    def interactive(self, interact):
        '''
        Defines if previewer works as a separate thread or not
        '''
        if self.state == Preview.STARTING:
            self.threading = not interact

    def start(self):
        '''
        Starts previewer
        '''
        # Initialization
        pygame.init()
        self.state = Preview.RUNNING
        if self.threading:
            threading.Thread.__init__(self)
            threading.Thread.start(self)
开发者ID:farbasmiah,项目名称:scenario4,代码行数:70,代码来源:preview.py


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