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


Python UI.start方法代码示例

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


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

示例1: __init__

# 需要导入模块: from ui import UI [as 别名]
# 或者: from ui.UI import start [as 别名]
class State:

    def __init__(self):
        """Create a reference to the UI, and establish the default nextState."""
        self.ui = UI(self)
        self.nextState = None

    def start(self):
        """Start the UI"""
        self.ui.start()
        self.ui = None

    def quit(self):
        """Perform any cleanup before exiting the current state."""
        pass

    def setup(self):
        """Hook: Create objects that know how to draw themselves."""
        pass

    def update(self, screen):
        """Hook: Draw things on the screen that change with every draw loop
        (animations)."""
        pass

    def handle(self, event):
        """Hook: Handle event."""
        pass

    def get_next_state(self):
        """Return the state to which to transition."""
        return self.nextState

    def transition(self):
        """Transition to the next state."""
        self.quit()
        next_state = self.get_next_state()
        self.ui.transition()
开发者ID:CodeSkool,项目名称:SimpleGUI2Pygame,代码行数:40,代码来源:state.py

示例2: Debugger

# 需要导入模块: from ui import UI [as 别名]
# 或者: from ui.UI import start [as 别名]
class Debugger(SocketManagerListener):
    def __init__(self):
        self.__ui = UI()
        self.__ui.setDebugger(self)

        self.__socketmanager = SocketManager()
        self.__socketmanager.setListener(self)

        self.__sessions = []
        self.__currentSession = None
        self.__commands = []
        self.__quit = False
        self.__newSessionCommands = []
        self.__currentLines = None
        self.__commandQueue = []
        self.__commandQueueLock = RLock()

    def getUI(self): return self.__ui
    def getSocketManager(self): return self.__socketmanager

    def getCurrentSession(self): return self.__currentSession
    def setCurrentSession(self, session): self.__currentSession = session

    def getNewSessionCommands(self): return self.__newSessionCommands[:]
    def setNewSessionCommands(self, commands): self.__newSessionCommands = commands
    
    def getSessions(self): return self.__sessions[:]

    def addSession(self, session):
        self.__sessions.append(session)
        if self.__currentSession is None: self.__currentSession = session

    def removeSession(self, session):
        self.__sessions.remove(session)
        if self.__currentSession == session: self.__currentSession = None

    def getCurrentRuntime(self):
        if self.getCurrentSession(): return self.getCurrentSession().getCurrentRuntime()
        else: return None
        
    def getCurrentThread(self):
        runtime = self.getCurrentRuntime()
        if runtime: return runtime.getCurrentThread()
        else: return None

    def addCommand(self, name, data):
        existing = [True for name0, realname0, command0 in self.__commands if name == name0]
        if existing: raise DebuggerError, "Command name already registered: %s" % name
        if type(data) == type(()): self.__commands.append((name, data[0], data[1]))
        else: self.__commands.append((name, name, data))

    def getCommandNames(self): return [realname for name, realname, command in self.__commands]

    def getCommandInvoker(self, line):
        try: name, arguments = line.split(' ', 1)
        except ValueError: name, arguments = line.strip(), ""
        try: name, options = name.split('/', 1)
        except ValueError: name, options = name, ""

        perfect = [(realname0, command0) for name0, realname0, command0 in self.__commands if name == name0]
        if perfect: return CommandInvoker(self, perfect[0][1], perfect[0][0], options, arguments)

        candidates = [(name0, realname0, command0) for name0, realname0, command0 in self.__commands if len(name) <= len(name0) and name0.startswith(name)]
        if len(candidates) == 1: return CommandInvoker(self, candidates[0][2], candidates[0][1], options, arguments)

        if len(candidates) == 0: message = "Unknown command: %s" % name
        else: message = "Ambiguous command.  Candidates are: %s" % ", ".join([name0 for name0, realname0, command0 in candidates])

        raise DebuggerError, message

    def execute(self, lines, withCurrentSession=None, withCurrentRuntime=None):
        currentSessionBefore = self.__currentSession
        currentRuntimeBefore = currentSessionBefore and currentSessionBefore.getCurrentRuntime()

        if withCurrentRuntime: withCurrentSession = withCurrentRuntime.getSession()
        if withCurrentSession:
            self.__currentSession = withCurrentSession
            if withCurrentRuntime:
                withCurrentSession.setCurrentRuntime(withCurrentRuntime)

        try:
            previousLines = self.__currentLines
            self.__currentLines = lines[:]
            while self.__currentLines:
                line = self.__currentLines.pop(0)
                if line:
                    output = self.getCommandInvoker(line)()
                    if output: self.getUI().writeln(*output)
        finally:
            self.__currentLines = previousLines
            if withCurrentSession:
                self.__currentSession = currentSessionBefore
                if withCurrentRuntime and currentSessionBefore:
                    currentSessionBefore.setCurrentRuntime(currentRuntimeBefore)

    def executeLater(self, lines, withCurrentSession=None, withCurrentRuntime=None):
        self.__commandQueueLock.acquire()
        try: self.__commandQueue.append((lines, withCurrentSession, withCurrentRuntime))
        finally: self.__commandQueueLock.release()

#.........这里部分代码省略.........
开发者ID:prestocore,项目名称:browser,代码行数:103,代码来源:debugger.py

示例3: UI

# 需要导入模块: from ui import UI [as 别名]
# 或者: from ui.UI import start [as 别名]
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import traceback
from ui import UI
from sounds import MasterVolume

if __name__ == "__main__":
    ui = UI()

    try:
        ui.start()

        master = MasterVolume()

        ui.run(master)
    except SystemExit:
        pass
    except:
        ui.end()
        traceback.print_exc()
开发者ID:Muges,项目名称:ambientsounds-curses,代码行数:32,代码来源:ambientsounds.py


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