本文整理汇总了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.