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


Python Display.stop方法代码示例

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


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

示例1: Client

# 需要导入模块: from display import Display [as 别名]
# 或者: from display.Display import stop [as 别名]
class Client(Happyboom, EventListener):
    """ The main class of the client of BoomBoom.
    @ivar display: Display manager of the game.
    @type display: C{L{BoomBoomDisplay}}
    @ivar input: Input manager of the game.
    @type input: C{L{BoomBoomInput}}
    @ivar __verbose: Verbose mode flag.
    @type __verbose: C{bool}
    @ivar __stopped: Stopped game flag.
    @type __stopped: C{bool}
    @ivar __stoplock: Mutex for synchronizing __stopped.
    @type __stoplock: C{thread.lock}
    """
    
    def __init__(self, args):
        """ BoomBoomClient constructor.
        @param host: Server hostname.
        @type host: C{str}
        @param display_port: Server port for "display"/"view" connection.
        @type display_port: C{int}
        @param input_port: Server port for "input" connection.
        @type input_port: C{int}
        @param verbose: Verbose mode flag.
        @type verbose: C{bool}
        @param debug: Debug mode flag.
        @type debug: C{bool}
        @param max_fps: Maximal number of frames per second, for optimization.
        @type max_fps: C{int}
        """
        args["protocol"] = protocol.loadProtocol("protocol.xml")
        args["features"] = ["game"] # Constant features
        
        Happyboom.__init__(self, args)
        EventListener.__init__(self, prefix="evt_")
        
        self.display = Display(args)
        self.input = Input(args)
        self.__verbose = args.get("verbose", False)
        self.registerEvent("happyboom")
        self.registerEvent("game")        
        
    def start(self):
        """ Starts the game client."""
        if self.__verbose:
            log.info("[BOOMBOOM] Starting client...")
        Happyboom.start(self)
        # Create thread for display
        thread.start_new_thread(self.displayThread, ())
        
        quit = False
        while not quit:
            self.input.process()
            time.sleep(0.100)
            quit = self.stopped
        
    def stop(self):
        """  Stops the game client."""
        if self.__verbose:
            log.info("[BOOMBOOM] Stopping client...")
        Happyboom.stop(self)
        self.launchEvent("happyboom", "disconnection", self._io, u"Quit.")
        self.display.stop()
        
    def evt_game_stop(self):
        self.stop()
        
    def evt_happyboom_stop(self):
        """ Stop event handler.
        """
        self.stop()
    
    def displayThread(self):
        """ Thread handler for the "display" part."""
        try:
            self.display.start()
        except Exception, msg:
            bt = getBacktrace()
            log.error("EXCEPTION IN DISPLAY THREAD:\n%s\n%s" % (msg, bt))
        try:
            self.stop()
        except Exception, msg:
            bt = getBacktrace()
            log.error("EXCEPTION (2) IN DISPLAY THREAD:\n%s\n%s" % (msg, bt))
开发者ID:BackupTheBerlios,项目名称:happyboom-svn,代码行数:85,代码来源:client.py


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