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


Python UI.homeViewController方法代码示例

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


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

示例1: main

# 需要导入模块: import UI [as 别名]
# 或者: from UI import homeViewController [as 别名]
def main():
    # The topLevelObjects is a list to store objects at the top level to listen for events.
    # A typical use should only have the navigationViewController inside it as the subclasses manage events
    global topLevelObjects      # Allow for the topLevelObjects list to be used elsewhere
    topLevelObjects = []

    # Initialise screen and pyGame
    pygame.init()
    screen = pygame.display.set_mode((800, 600))
    # Set the window title
    pygame.display.set_caption('Squares')

    # initialisation of the navigation controller.
    navigationViewController = NWPi.navigationController(screen)             # Create a navigation view controller. Will parent all the Viewcontrollers
    topLevelObjects.append(navigationViewController)                    # This will now be added to topLevelObjects so it can recieve events

    # draw each viewController to the navigation controller
    home = UI.homeViewController(navigationViewController)                 # Create a ViewController, from subclass homeViewController where all elements are already defined
    navigationViewController.addSubView("HOMEVIEWCONTROLLER", home)     # Add the ViewController to the navigation Controller. Do the same with the rest.

    secondView = UI.instructionsViewController(navigationViewController)
    navigationViewController.addSubView("INSTRUCTIONS", secondView)

    gameView = UI.mainGameViewController(navigationViewController)
    navigationViewController.addSubView("GAMEVIEW", gameView)

    # We need to set a viewController to show as the top level. Choose it here:
    navigationViewController.makeKeyAndVisible("INSTRUCTIONS")    # Tell the navigation controller to set the view with the specified identifier to the top

    # We need a loop to keep the script running. Defining it here
    while True:
        loop()  # Run the loop() function we defined earlier.
开发者ID:nickw444,项目名称:NWPi,代码行数:34,代码来源:game.py


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