def startDisplay(self): self.main_menu = MainMenu() self.main_menu.init() self.main_menu.secretsCallback = self.listSecrets self.main_menu.secretCallback = self.retrieveSecret self.main_menu.saltCallback = self.initEncryption self.main_menu.display()
def __init__(self): pygame.init() # Initialize screen, and sets screen size self.surface = pygame.display.set_mode(size=(720, 640), flags=pygame.DOUBLEBUF) pygame.display.set_caption('Testing Game') self.game_state_manager = GameStateManager(self.surface, MainMenu(self.surface)) self.clock = pygame.time.Clock() # Creates instance of clock class
def __init__(self): themed_tk.ThemedTk.__init__(self) self.set_theme("arc") ttk.Style(self) self.horizontal_panel = ttk.PanedWindow(self, orient="horizontal") self.vertical_panel = ttk.PanedWindow(self, orient="vertical") self.side_view = Notebook(self, has_labels=True) self.node = NodeEditor(self) self.console = Interpreter(self) self.modules = ModuleTree(self) self.objects = ObjectTree(self) self.vertical_panel.add(self.node.frame) self.vertical_panel.add(self.console.frame) self.side_view.add("Modules", self.modules) self.side_view.add("Objects", self.objects) self.horizontal_panel.add(self.side_view.frame) self.horizontal_panel.add(self.vertical_panel) self.horizontal_panel.pack(side="left", fill="both", expand=True) self.animate = Animation(self) self.project = SaveData(self) self.menu = MainMenu(self) self.config(menu=self.menu) self.project.load(is_first_load=True)
def test_add_task(self, mock_stdout): # Test adding task with a date provided main_menu = MainMenu() test_name = "John Doe" task_title = "Testing Task Title2" task_timespent = "30" task_notes = "coding!" datestr = "03/18/1981" prompts = [ test_name, datestr, task_title, task_timespent, task_notes, 'y', 'q' ] with mock.patch('builtins.input', side_effect=prompts): added_successfully = main_menu.add_task() self.assertTrue(added_successfully) # test adding task without date task_title = "Testing Task Title3" prompts = [ test_name, "", task_title, task_timespent, task_notes, 'y', 'q' ] with mock.patch('builtins.input', side_effect=prompts): added_successfully = main_menu.add_task() self.assertTrue(added_successfully)
def test_delete_task(self, mock_stdout): main_menu = MainMenu() test_name = "John Doe" task_title = "Testing Task To be deleted" task_timespent = "1" task_notes = "to be deleted" datestr = "07/04/1776" prompts = [ test_name, datestr, task_title, task_timespent, task_notes, 'y', 'q' ] with mock.patch('builtins.input', side_effect=prompts): main_menu.add_task() task_search = TaskSearch() prompts = ["07/04/1776", 'd', 'y', 'q', 'q'] with mock.patch('builtins.input', side_effect=prompts): task_search.search_by_taskdate() sdate = convertdate("07/04/1976") tasks = Task.select().where( Task.timestamp.year == sdate.year \ and Task.timestamp.month == sdate.month \ and Task.timestamp.day == sdate.day) self.assertEquals(len(tasks), 0)
def start_screen(self): funcs = {'New Game': self.new, 'Load': self.load_game, 'Options': self.options, 'Quit': self.quit} mm = MainMenu(self.screen, funcs.keys(), funcs) mm.menu_run()
def main(): pygame.init() pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) pygame.display.set_caption('pyAsteroids') screen = pygame.display.get_surface() MainMenu(screen)
def __init__(self): self.screenSize = (800, 600) self.backgroundColor = (230, 230, 230) self.screen = pygame.display.set_mode(self.screenSize) self.clock = pygame.time.Clock() self.sceneStack = Stack() self.sceneStack.push(MainMenu(self)) pygame.display.set_caption("Final Flautist")
def __init__(self): ShowBase.__init__(self) self.root_node = None self.clean_up() self.set_background_color(0, 0, 0) self.game = Game(self, self.main_menu) self.mm = MainMenu(self, self.start_game) self.main_menu()
def test_add_task_employee_not_found(self, mock_stdout): main_menu = MainMenu() test_name = "Employee Notfound" task_title = "Testing Task Title" task_timespent = "30" task_notes = "Testing out code" prompts = [ test_name, " ", task_title, task_timespent, task_notes, 'y', 'q' ] with mock.patch('builtins.input', side_effect=prompts): added_successfully = main_menu.add_task() self.assertFalse(added_successfully)
def build(self): sm = ScreenManager() menu = MainMenu(name='menu') sed = StartEndDate(name='sed') settingscreen = SettingsScreen(name="settingscreen") task = TaskScreen(name='task') task_results = TaskResultsScreen(name='task_results') sm.add_widget(menu) sm.add_widget(task) sm.add_widget(settingscreen) sm.add_widget(sed) sm.add_widget(task_results) return sm
def initPages(self): self.mode_stack = QtGui.QStackedWidget() main_menu = MainMenu(self) #0 self.stats = Statistics(self) #1 self.trainer = Trainer(self, self.stats) #2 self.generator = Generator(self) #3 self.mode_stack.addWidget(main_menu) self.mode_stack.addWidget(self.stats) self.mode_stack.addWidget(self.trainer) self.mode_stack.addWidget(self.generator) self.setCentralWidget(self.mode_stack)
def __init__(self): tk.Tk.__init__(self) self.title("Frame 2000") self.state('zoomed') self.iconbitmap('icon_beam_2000.ico') self.resizable(False, False) # Create instances of window content self.menubar = Menubar(self) self.canvas = Canvas(self) self.main_menu = MainMenu(self) # Place the instances in the window self.canvas.pack(side="left", fill="both", expand=1, pady=20, padx=20) self.main_menu.pack(side="right", fill=tk.Y, padx=10)
def run_game(): '''Run Game of Life.''' pygame.init() game_settings = Settings() screen = pygame.display.set_mode((game_settings.screen_width, game_settings.screen_height)) pygame.display.set_caption("Game of Life") # There is only one cell. cell = Cell(screen, game_settings) # Set main menu. main = MainMenu() # Set available options. options = Options(screen, game_settings) # Set speed and speed bar. speed = Speed(screen, game_settings) to_drop = [speed.actual_drop] # Set pause menu. state = Status(screen) # Build the matrix for live cells coordinates. mat_rows = game_settings.screen_height // game_settings.cell_height + 2 mat_cols = game_settings.screen_width // game_settings.cell_width + 2 cells_matrix = np.zeros(shape = (mat_rows, mat_cols)).astype(bool) xmouse, ymouse = None, None # Set to False the single step option. move_to_next_step = [False] while 1: gf.check_events(state, speed, main, options, xmouse, ymouse, move_to_next_step) if main.menu: xmouse, ymouse = pygame.mouse.get_pos() gf.main_menu(xmouse, ymouse, game_settings, state, speed, main, options, cells_matrix) elif not state.pause or move_to_next_step[0]: gf.game(move_to_next_step, cells_matrix, game_settings, state, speed, to_drop) gf.update_screen(game_settings, screen, cells_matrix, state, speed, main, options, cell)
def __init__(self): tk.Tk.__init__(self) self.title("Frame 2000") self.state('zoomed') self.iconbitmap('icon_beam_2000.ico') self.resizable(False, False) # Create a list for storing instances of the element class self.element_list = [] # Create a dictionary to store the topology information self.edof = np.empty((0, 7), float) # Create instances of window content self.menubar = Menubar(self) self.canvas = Canvas(self) self.main_menu = MainMenu(self) # Place the instances in the window self.canvas.pack(side="left", fill="both", expand=1, pady=20, padx=20) self.main_menu.pack(side="right", fill=tk.Y, padx=10)
def main(self): """ Lancement du jeu """ pygame.init() # Lance de Pygame screen = pygame.display.set_mode( (self.width, self.height)) # Crée la fenêtre pygame.display.set_caption( 'PyDragon v0.4') # Donne un nom à la fenêtre pygame.display.set_icon(pygame.image.load( self.favicon)) # Favicon du jeu self.son = pygame.mixer.Sound( "ressources/sounds/DBZFighter.wav") # Défini le son du jeu self.son.set_volume(0.3) # Permet de diminuer le son par défaut du jeu clock = pygame.time.Clock() # Calcule le temps de départ pour les FPS while Niveau.WHILE_GAME: # Boucle principale qui sert aux importations de maps if Niveau.LVL == 'while_main_menu': # Nom défini qui orchestre tous les imports liés main_menu = MainMenu( screen, clock, self.fps, self.son ) # Instancie la class qui affiche le menu de départ main_menu.while_menu() # Boucle sur le menu elif Niveau.LVL == 'while_map_kamehouse': map_kamehouse = Kamehouse(self.width, self.height, screen, clock, self.fps, self.avancer) map_kamehouse.while_kamehouse() # Boucle sur la map elif Niveau.LVL == 'while_map_kamehouse_in': map_kamehouse_in = KamehouseIn(self.width, self.height, screen, clock, self.fps, self.avancer) map_kamehouse_in.while_kamehouse_in() # Boucle sur la map elif Niveau.LVL == 'while_map_town': map_world = WorldTown(self.width, self.height, screen, clock, self.fps, self.avancer) map_world.while_town() # Boucle sur la map elif Niveau.LVL == 'while_map_town_in': map_world = WorldTownIn(self.width, self.height, screen, clock, self.fps, self.avancer) map_world.while_town_in() # Boucle sur la map pygame.quit() # Arrête le processus de PyGame
def __init__(self): super().__init__() self.mainMenu = MainMenu() self.selectGame = SelectGame() self.settings = Settings() self.installGames = InstallGames() self.manageCharacters = ManageCharacters() self.viewCharacter = ViewCharacter() self.addWidget(self.mainMenu) self.addWidget(self.selectGame) self.addWidget(self.settings) self.addWidget(self.installGames) self.addWidget(self.manageCharacters) self.addWidget(self.viewCharacter) self.mainMenu.setCreateCharacterCallback(self.showSelectGame) self.mainMenu.setManageCharactersCallback(self.showManageCharacters) self.mainMenu.setSettingsCallback(self.showSettings) self.selectGame.setBackCallback(self.showMainMenu) self.selectGame.setInstallGamesCallback(self.showInstallGames) self.settings.setBackCallback(self.showMainMenu) self.installGames.setBackCallback(self.showSelectGame) self.manageCharacters.setBackCallback(self.showMainMenu) self.manageCharacters.setViewCallback(self.showViewCharacter) self.viewCharacter.setBackCallback(self.showManageCharacters)
def test_menu_loop(self, mock_stdout): main_menu = MainMenu() with mock.patch('builtins.input', side_effect=['s', 'q', 'q']): return_value = main_menu.menu_loop() self.assertTrue(return_value)
def startMainmenu(self): self.login.hide() self.mainmenu = MainMenu(self) self.pregame = Pregame(self) self.mainmenu.show()
def __init__(self): log.debug('Starting UserInterface') #load fonts self.font = loader.loadFont(path + cfg['font-default']) self.font.setPixelsPerUnit(17) self.font.setMinfilter(Texture.FTNearest) self.font.setMagfilter(Texture.FTNearest) self.font_special = loader.loadFont(path + cfg['font-special']) self.font_special.setPixelsPerUnit(48) self.font_special.set_outline((1, 1, 1, 0.5), 3, 0.6) self.font_special.setMinfilter(Texture.FTNearest) self.font_special.setMagfilter(Texture.FTNearest) #text properties tp_red = TextProperties() tp_red.setTextColor(0.94, 0.0, 0.1, 1.0) tp_blue = TextProperties() tp_blue.setTextColor(0.1, 0.4, 1.0, 1.0) tp_cyan = TextProperties() tp_cyan.setTextColor(0.33, 0.894, 1.0, 1.0) tpMgr = TextPropertiesManager.getGlobalPtr() tpMgr.setProperties("red", tp_red) tpMgr.setProperties("blue", tp_blue) tpMgr.setProperties("cyan", tp_cyan) #set nodes for gui placement self.top_left = pixel2d.attachNewNode('TopLeft') self.top_right = pixel2d.attachNewNode('TopRight') self.bottom_right = pixel2d.attachNewNode('BottomRight') self.bottom_left = pixel2d.attachNewNode('BottomLeft') self.top = pixel2d.attachNewNode('Top') self.bottom = pixel2d.attachNewNode('Bottom') self.left = pixel2d.attachNewNode('Left') self.right = pixel2d.attachNewNode('Right') self.center = pixel2d.attachNewNode('Center') pixel2d.setShaderInput('strip', loader.loadTexture(path + 'gui/strip.png')) #make the main menu self.main_menu = MainMenu(self) #make the in-game menu self.in_game_menu = InGameMenu(self) self.in_game_menu.hide() if cfg['show-frame-rate-meter']: self.fps_node = NodePath(base.frameRateMeter) self.fps_node.wrtReparentTo(self.top_right) self.fps_node.setPos(-128, 0, 0) #mouse cursor cursor_tex = path + 'gui/pointer1.png' if cfg['use-os-cursor']: cursor_tex = path + 'gui/empty_64.png' self.cursor = self.main_menu.makeFrame(cursor_tex, pixel2d, (0, 0), (32, 32)) self.cursor_pos = (0, 0, 0) #place the nodes at the right places self.updateGuiNodes() #keybinding self.key_map = { 'back': False, 'fire': False, 'forward': False, 'left': False, 'right': False, 'jump': False } #vars self.is_zoomed = False self.is_main_menu = True # Task taskMgr.add(self.update, 'ui_update')
pygame.display.set_caption('Glarf') #pygame.mouse.set_visible(0) #Create The Backgound bgMangr = SeamedBackgroundManager(screen) #Display The Background screen.blit(bgMangr.GetBackground(), (0, 0)) pygame.display.flip() #Prepare Game Objects clock = pygame.time.Clock() musicMangr = MusicManager() displayer = MainMenu(bgMangr, musicMangr) #Main Loop oldfps = 0 while 1: timeChange = clock.tick(40) newfps = int(clock.get_fps()) #if newfps != oldfps: #print "fps: ", newfps #oldfps = newfps #Handle Input Events remainingEvents = pygame.event.get() for event in remainingEvents: upKeys = filter(allKUPs, remainingEvents) if event.type == QUIT:
def start_mainmenu(self, task): self.login.destroy() self.mainmenu = MainMenu(self) return task.done
from searchspreadsheet import SearchSpreadsheet from countcolumninstances import CountColumnInstances from createcertificates import CreateCertificates from mainmenu import MainMenu main_menu = MainMenu() if main_menu.choice == "1": SearchSpreadsheet() if main_menu.choice == "2": CountColumnInstances() if main_menu.choice == "3": CreateCertificates()
def NodeAdmin(): MainMenu()
def postInit(self): # Some game related variables self.currentLevel = 1 self.youWon = False # Set esc to force exit $ remove self.accept('escape', self.exitApp) # Menu Events self.accept("menu_StartGame", self.startGame) self.accept("menu_Options", self.request, ["Options"]) self.accept("menu_QuitGame", self.exitApp) self.accept("menu_Back", self.request, ["Menu"]) self.accept("n", self.playNextTrack) ## Load Menu self.mainMenu = MainMenu() self.optionsMenu = OptionsMenu() ## Load music list self.musicList = [ [ "Housewell - Housewell - Sea Sun Fun", loader.loadMusic( "music/Housewell_-_Housewell_-_Sea__Sun__Fun.ogg") ], [ "KontrastE - LISTEN TO NIGHT", loader.loadMusic("music/KontrastE_-_LISTEN_TO_NIGHT.ogg") ], [ "LukHash - THE OTHER SIDE", loader.loadMusic("music/LukHash_-_THE_OTHER_SIDE.ogg") ], [ "Axl & Arth - Breathe", loader.loadMusic("music/Axl__amp__Arth_-_Breathe.ogg") ], [ "Lyonn - The Symphony", loader.loadMusic("music/Lyonn_-_The_Symphony.ogg") ], ] self.lblNowPlaying = DirectLabel(text="No track running!", text_align=TextNode.ARight, text_fg=(240 / 255.0, 255 / 255.0, 240 / 255.0, 0.75), pos=(base.a2dRight - 0.05, 0, base.a2dBottom + 0.1), scale=0.04, frameColor=(0, 0, 0, 0.5), sortOrder=10) self.lblNowPlaying.hide() # The games Intro def create16To9LogoCard(logoPath, tsName): cm = CardMaker("fade") scale = abs(base.a2dLeft) / 1.7776 cm.setFrame(-1, 1, -1 * scale, 1 * scale) logo = NodePath(cm.generate()) logo.setTransparency(TransparencyAttrib.MAlpha) logoTex = loader.loadTexture(logoPath) logoTs = TextureStage(tsName) logoTs.setMode(TextureStage.MReplace) logo.setTexture(logoTs, logoTex) logo.setBin("fixed", 5000) logo.reparentTo(render2d) logo.hide() return logo self.gfLogo = create16To9LogoCard("intro/GrimFangLogo.png", "gfLogoTS") self.pandaLogo = create16To9LogoCard("intro/Panda3DLogo.png", "pandaLogoTS") self.gameLogo = create16To9LogoCard("intro/GameLogo.png", "gameLogoTS") def createFadeIn(logo): return LerpColorScaleInterval(logo, 2, LVecBase4f(0.0, 0.0, 0.0, 1.0), LVecBase4f(0.0, 0.0, 0.0, 0.0)) def createFadeOut(logo): return LerpColorScaleInterval(logo, 2, LVecBase4f(0.0, 0.0, 0.0, 0.0), LVecBase4f(0.0, 0.0, 0.0, 1.0)) gfFadeInInterval = createFadeIn(self.gfLogo) gfFadeOutInterval = createFadeOut(self.gfLogo) p3dFadeInInterval = createFadeIn(self.pandaLogo) p3dFadeOutInterval = createFadeOut(self.pandaLogo) gameFadeInInterval = createFadeIn(self.gameLogo) gameFadeOutInterval = createFadeOut(self.gameLogo) self.introFadeInOutSequence = Sequence(Func(self.gfLogo.show), gfFadeInInterval, Wait(1.0), gfFadeOutInterval, Wait(0.5), Func(self.gfLogo.hide), Func(self.pandaLogo.show), p3dFadeInInterval, Wait(1.0), p3dFadeOutInterval, Wait(0.5), Func(self.pandaLogo.hide), Func(self.gameLogo.show), gameFadeInInterval, Wait(1.0), gameFadeOutInterval, Wait(0.5), Func(self.gameLogo.hide), Func(self.messenger.send, "intro_done"), Func(self.startMusic), name="fadeInOut") # game intro end # story intro self.storyImage1 = create16To9LogoCard("intro1.png", "storyIntro1TS") story1FadeInInterval = createFadeIn(self.storyImage1) story1FadeOutInterval = createFadeOut(self.storyImage1) self.storySequence = Sequence(Func(self.storyImage1.show), story1FadeInInterval, Wait(8.0), story1FadeOutInterval, Func(self.request, "Game"), name="story") # Outros self.outroImage1 = create16To9LogoCard("outro1.png", "storyOutro1TS") outro1FadeInInterval = createFadeIn(self.outroImage1) outro1FadeOutInterval = createFadeOut(self.outroImage1) self.outroWonSequence = Sequence(Func(self.outroImage1.show), outro1FadeInInterval, Wait(8.0), outro1FadeOutInterval, Func(self.request, "Game"), name="OutroWon") self.outroImage2 = create16To9LogoCard("outro2.png", "storyOutro2TS") outro2FadeInInterval = createFadeIn(self.outroImage2) outro2FadeOutInterval = createFadeOut(self.outroImage2) self.outroLostSequence = Sequence(Func(self.outroImage2.show), outro2FadeInInterval, Wait(8.0), outro2FadeOutInterval, Func(self.request, "Menu"), name="OutroLost") self.outroImage3 = create16To9LogoCard("outro3.png", "storyOutro3TS") outro3FadeInInterval = createFadeIn(self.outroImage3) outro3FadeOutInterval = createFadeOut(self.outroImage3) self.outroWonGameSequence = Sequence(Func(self.outroImage3.show), outro3FadeInInterval, Wait(8.0), outro3FadeOutInterval, Func(self.request, "Menu"), name="OutroWonGame") # # Start with the menu after the intro has been played # self.introFadeInOutSequence.start() self.accept("intro_done", self.request, ["Menu"])
for event in pg.event.get(): if event.type == pg.QUIT: self.done = True self.state.get_event(event) def main_game_loop(self): while not self.done: delta_time = self.clock.tick(60) / 1000 self.event_loop() self.update(delta_time) pg.display.update() #Settings from above dictionary get passed into Control class #Control creates app object. #Then, each state (Menu & Game) object get assigned to a dicitonary. #This allows control to be able to switch to and from any state as needed. app = Control() #State Dictionary. Include all state classes here. state_dict = {'mainmenu': MainMenu(), 'game': Game(), 'gameover': GameOver()} #Setup State is called and sets the initial state of the program app.setup_states(state_dict, 'mainmenu') #Call main game loop that runs whole program app.main_game_loop() pg.quit() sys.exit()
def build(self): return MainMenu()