def __init__(self, app_name, root_view, app=None, components=[]): TopLevelMenu.__init__(self) self.app_name = app_name self.menu = {"left": MainMenu(), "right": MainMenu()} self.system_module = None self.babel = mydomain self.root_view = root_view self.component_config = components self.search_view = None self.base_templates = {"plain": "appshell/base_plain.html"} self.access_map = {} if app: self.init_app(app)
class BankCRM: menu = MainMenu() def run(self): while True: self.menu.display_menu() choice = input("Enter an option: ") item = self.menu.choices.get(choice) if item and item in (self.menu.credit_menu, self.menu.investor_menu): while True: item.display_menu() choice = input("Enter an option: ") action = item.choices.get(choice) if action == item.quit: break if action: action() else: print("{0} is not a valid choice".format(choice)) continue elif item: item() else: print("{0} is not a valid choice".format(choice))
def __init__(self): pygame.init() self.running = True # When the application is running self.playing = False # When the game is actually being played self.UP_KEY, self.DOWN_KEY, self.START_KEY, self.BACK_KEY = False, False, False, False # START_KEY = ENTER self.I_KEY, self.M_KEY = False, False self.DISPLAY_H = 600 self.DISPLAY_W = 600 self.mid_width = self.DISPLAY_W/2 self.mid_height = self.DISPLAY_H/2 self.twelth_x = self.DISPLAY_W / 12 self.twelth_y = self.DISPLAY_H / 12 #Initialise window self.window = pygame.display.set_mode((self.DISPLAY_W, self.DISPLAY_H)) pygame.display.set_caption("SOME COOL GAME NAME") self.display = pygame.Surface((self.window.get_size())) self.font = pygame.font.SysFont("Courier", 20) self.action_font = pygame.font.SysFont("Courier", 16) self.legend_font = pygame.font.SysFont("Courier", 12) self.BLACK = (0,0,0) self.GREEN = (0,255,0) self.main_menu = MainMenu(self) self.options_menu = OptionsMenu(self) self.credits_menu = CreditsMenu(self) self.level_one_map = LevelOneMap(self) self.curr_menu = self.main_menu self.current_screen = '' self.all_options_selected = [] # Current menu. Self (current Game instance) given as parameter as MainMenu requires a game to be passed in. self.level_one = LevelOne(self) self.current_level = 0
def __init__(self): pygame.init() self.level = 0 self.checkanswer = True self.running = True self.playing = False self.game_over = False self.paused = False self.UP, self.DOWN, self.LEFT, self.RIGHT, self.START, self.BACK = False, False, False, False, False, False self.allow_pausing = True self.player = rocket(self) self.rock = asteroid(self) self.windowX, self.windowY = 1200, 700 self.display = pygame.Surface((self.windowX, self.windowY)) self.screen = pygame.display.set_mode([self.windowX, self.windowY]) self.font_name = 'fonts/game_over.ttf' self.font_game = 'fonts/OpenSans-Light.ttf' pygame.display.set_caption("Rocket Logic: Not quite rocket science") self.main_menu = MainMenu(self) self.instr_menu = InstructionsMenu(self) self.options_menu = OptionsMenu(self) self.credits_menu = CreditsMenu(self) self.curr_menu = self.main_menu self.get_new_equation()
def __init__(self): self.window = Window(Game.WINDOW_WIDTH, Game.WINDOW_HEIGHT) self.window.set_title(Game.TITLE) self.keyboard = self.window.get_keyboard() self.mouse = self.window.get_mouse() self.menuPool = [] if (Game.DEBUG): self._frameRate = 0 self.frameRate = 0 self.timer = 0 self.mainMenu = MainMenu(self) self.difficultyMenu = DifficultyMenu(self) self.menuPool.append(self.mainMenu) self.menuPool.append(self.difficultyMenu) self.life = Game.MAX_LIFE self.difficulty = 1 self.score = 0 self.inGame = False
def __init__(self, app): super(MainWindow, self).__init__() self.app = app print('window created') self.setWindowIcon(QIcon('img/icon.png')) self.setWindowTitle('Kasino') self.setPalette(QPalette(Qt.darkGreen)) self.setup_music() self.statusbar = QStatusBar(self) self.statusbar.setStyleSheet('background: white') self.setStatusBar(self.statusbar) self.statusbar.showMessage('Welcome to the Cassino game!') self.menubar = QMenuBar(self) self.optionsMenu = self.menubar.addMenu('Options') self.music_toggle = QAction() self.music_toggle.setText('Music') self.music_toggle.setShortcut('Ctrl+m') self.music_toggle.setCheckable(True) self.music_toggle.setChecked(True) self.optionsMenu.addAction(self.music_toggle) self.music_toggle.triggered.connect(self.toggle_music) self.speedGroup = QActionGroup(self) self.speedGroup.triggered.connect(self.set_speed) self.slow_speed = QAction('Slow', self.speedGroup) self.slow_speed.setCheckable(True) self.normal_speed = QAction('Normal', self.speedGroup) self.normal_speed.setCheckable(True) self.fast_speed = QAction('Fast', self.speedGroup) self.fast_speed.setCheckable(True) self.vfast_speed = QAction('Very Fast', self.speedGroup) self.vfast_speed.setCheckable(True) self.normal_speed.setChecked(True) self.speed_menu = self.optionsMenu.addMenu('Speed') self.speed_menu.addActions(self.speedGroup.actions()) self.menubar.setMouseTracking(False) self.setMenuBar(self.menubar) self.play_widget = PlayWidget(self) self.main_menu = MainMenu(self) self.start_menu = StartMenu(self) self.widgets = QStackedWidget(self) self.widgets.addWidget(self.play_widget) self.widgets.addWidget(self.main_menu) self.widgets.addWidget(self.start_menu) self.widgets.setCurrentWidget(self.main_menu) self.setCentralWidget(self.widgets) self.setGeometry(25, 50, 1028, 720) self.main_menu.startbutton.clicked.connect(self.init_game) self.main_menu.loadbutton.clicked.connect(self.load_game) self.main_menu.quitbutton.clicked.connect(self.quit) self.play_widget.quit_button.clicked.connect(self.quit_to_menu) self.play_widget.save_button.clicked.connect(self.save_game) self.start_menu.startbutton.clicked.connect(self.start_game)
def createWidgets(self): # 创建一个Text self.text = tkinter.Text(self,width=550, height=650) self.text.pack() # 将主菜单栏加到根窗口 menu = MainMenu(root) menu.createWidget() self.mainMenu = menu.getMenu() #添加快捷键事件处理 self.root.bind("<Control-n>",lambda event:self.newfile()) self.root.bind("<Control-o>",lambda event:self.openfile()) self.root.bind("<Control-s>",lambda event:self.savefile()) self.root.bind("<Control-q>",lambda event:self.exit()) menu.bindMenuFile(newfile=self.newfile, openfile=self.openfile, savefile=self.savefile, exit=self.exit) quickMenu = QuickMenu(self.root) quickMenu.createWidget() quickMenu.bindMenu(changeBG=self.changBG) self.quickMenu = quickMenu.menu self.root["menu"] = self.mainMenu #为右键绑定事件 self.root.bind("<Button-2>",self.showQuickMenu)
def __init__(self, option_handler): self.option_handler = option_handler self.state = State.MENU self.level = Level() self.players = dict() self.colliders = [] self.time_scale = 1.0 self.camera = Camera([0, 0], self.option_handler.resolution) self.respawn_time = 50.0 self.menu = MainMenu() self.player_menus = [ PlayerMenu((6 * i - 9) * basis(0)) for i in range(4) ] self.options_menu = OptionsMenu() self.options_menu.set_values(self.option_handler) self.network = None self.network_id = -1 self.obj_id = -1 self.controller_id = 0
def setup(self): """Set up the game""" # set the default state self.state_change = False self.state = GameStates.MAIN_MENU # setup the background self.background = Background() self.background.center_x = SCREEN_WIDTH / 2 self.background.center_y = SCREEN_HEIGHT / 2 # setup the main menu self.main_menu = MainMenu() self.main_menu.center_x = SCREEN_WIDTH / 2 self.main_menu.center_y = SCREEN_HEIGHT / 2 # setup the pause menu self.pause_menu = PauseMenu() self.pause_menu.center_x = SCREEN_WIDTH / 2 self.pause_menu.center_y = SCREEN_HEIGHT / 2 # setup the game over screen self.game_over_screen = GameOverMenu() self.game_over_screen.center_x = SCREEN_WIDTH / 2 self.game_over_screen.center_y = SCREEN_HEIGHT / 2 # setup the highscores self.load_scores() # setup the scoreboard self.score_board = ScoreBoard() self.score_board.center_x = SCREEN_WIDTH / 2 self.score_board.center_y = SCREEN_HEIGHT / 2 # setup the player self.player = Player() self.player.center_x = SCREEN_WIDTH / 2 self.player.center_y = SCREEN_HEIGHT / 2 # setup the creatures self.all_creature_sprites_list = arcade.SpriteList() for i in range(self.current_creature_amount): rand = random.randint(1, 2) if rand == 1: creature = Moth() elif rand == 2: creature = Bug() creature.setup() self.all_creature_sprites_list.append(creature) # setup the obstacles self.all_obstacle_sprite_list = arcade.SpriteList() for i in range(MAX_OBSTACLE_COUNT): obstacle = Obstacle() obstacle.setup() self.all_obstacle_sprite_list.append(obstacle)
def ValidarUser(): user = str(entryuser.get()) password = str(entrypassword.get()) # User(user) connection = mysql.connector.connect(host="localhost",user="******",password="",database="bdlanchonete") mycursor = connection.cursor() sqlselect = "select * from usuarios where nome like '"+user+"' and senha like '"+password+"' " # like (parecido com) #print(sqlselect) mycursor.execute(sqlselect) valido = mycursor.fetchall() if len(valido) > 0: connection = mysql.connector.connect(host="localhost",user="******",password="",database="bdlanchonete") mycursor = connection.cursor() sqlselectUsuario = "select * from log_usuario " # like (parecido com) mycursor.execute(sqlselectUsuario) validarUsuario = mycursor.fetchall() if len(validarUsuario) > 0: connection = mysql.connector.connect(host="localhost",user="******",password="",database="bdlanchonete") mycursor = connection.cursor() sqlDeleteUsuario = "DELETE FROM log_usuario " mycursor.execute(sqlDeleteUsuario) connection.commit() sqlInsertUsuario = "INSERT INTO log_usuario(nome) VALUES('{}')".format(user) mycursor.execute(sqlInsertUsuario) connection.commit() else: connection = mysql.connector.connect(host="localhost",user="******",password="",database="bdlanchonete") mycursor = connection.cursor() sqlInsertUsuario = "INSERT INTO log_usuario(nome) VALUES('{}')".format(user) mycursor.execute(sqlInsertUsuario) connection.commit() window.destroy() MainMenu() else: messagebox.showwarning("Warning","Usuário ou senha inválida!") # entryuser.delete(0, END) entrypassword.delete(0, END) entrypassword.focus() mycursor.close() connection.commit() connection.close()
def __init__(self): pygame.init() self.exit = False self.framerate = 60 self.clock = None self.delta_time = 0 self.tabs = {} self.add_tab('game', Game(self)) self.add_tab('mainmenu', MainMenu(self)) self.current_tab = self.get_tab('mainmenu') self.current_tab.start() self.screen = pygame.display.set_mode(self.current_tab.get_size().floor().get()) Painter.init(self.screen)
def MainMenuStart(): #Code below makes the first MainMenu instance work #and delete Game instances if a new MainMenu is created try: del(CurrentRun) except NameError: pass global MainMenu #Starts Main Menu loop in file menu.py MenuInstance = MainMenu() MenuInstance.mm_loop() IntroStart(MenuInstance)
def __init__(self): pygame.init() self.running, self.playing = True, False self.UP_KEY, self.DOWN_KEY, self.START_KEY, self.BACK_KEY = False, False, False, False self.DISPLAY_W, self.DISPLAY_H = 600, 800 self.display = pygame.Surface((self.DISPLAY_W, self.DISPLAY_H)) self.window = pygame.display.set_mode((self.DISPLAY_W, self.DISPLAY_H)) self.font_name = pygame.font.match_font("comicsansms") self.font = pygame.font.Font(None, 32) self.BLACK, self.WHITE = (0, 0, 0), (255, 255, 255) self.main_menu = MainMenu(self) self.options = OptionsMenu(self) self.credits = CreditsMenu(self) self.controls = ControlsMenu(self) self.volume = VolumeMenu(self) self.current_menu = self.main_menu
def __init__(self): pygame.init() self.running, self.playing = True, False self.UP_KEY, self.DOWN_KEY, self.START_KEY, self.BACK_KEY = False, False, False, False self.DISPLAY_W, self.DISPLAY_H = 800, 800 self.display = pygame.Surface((self.DISPLAY_W, self.DISPLAY_H)) self.window = pygame.display.set_mode( ((self.DISPLAY_W, self.DISPLAY_H))) self.font_name = 'LobsterTwo-Bold.otf' self.font_name2 = 'SEASRN__.ttf' self.font_name1 = pygame.font.get_default_font() self.BLACK, self.WHITE = (0, 0, 0), (255, 255, 255) self.main_menu = MainMenu(self) #self.options = OptionsMenu(self) #self.credits = CreditsMenu(self) self.curr_menu = self.main_menu
def __initGame(self): """ Probably going to be a good idea to move the majority of these configs to a config file ...soon as I create a ini object """ environ['SDL_VIDEO_CENTERED'] = '1' pygame.init() self.clock = pygame.time.Clock() self.running = True self.fullscreen = False if G["fullscreen"] == True: self.screen = pygame.display.set_mode((G["screen_width"], G["screen_height"]), pygame.FULLSCREEN, G["color_depth"]) else: self.screen = pygame.display.set_mode((G["screen_width"], G["screen_height"]), 0, G["color_depth"]) self.fps = self.clock.get_fps() pygame.mouse.set_visible(False) self.GameMenu = MainMenu(self.screen) self.RunWorld = False
def __init__(self, title="", sWidth=1280, sHeight=720, bgC=color_rgb(25, 25, 25)): self.window = GraphWin(title, sWidth, sHeight) self.window.setBackground(bgC) self.gameState = GameState.MENU self.menu = MainMenu(self.window) self.game = Game(self.window, False) self.dt = 0.0 #DeltaTime self.lastFrameTime = 0.0 self.setState(self.gameState)
def __init__(self, debug=False): self.debug = debug ## Centers game window, needs to be before pygame.init() os.environ['SDL_VIDEO_CENTERED'] = '1' self.state = S_MENU self.fps = FPS self.paused = False self.all_player_names = [] self.wait = 1500 #WAITING TIME AFTER FIRST PLAYER DIES, BEFORE MENU SHOWS UP. IN MILLISECONDS. self.keymap = {} #REGISTER KEPRESS CONSTANTLY self.keymap_singlepress = {} #REGISTER KEYPRESS ONE TIME self.events = {} #REGISTER EVENT #PYGAME INIT REQUIRED pygame.init() self.screen = pygame.display.set_mode(SCREEN_SIZE) pygame.display.set_caption(CAPTION) self.font = pygame.font.Font("fonts/04b.ttf", 18) self.scorefont = pygame.font.Font("fonts/04b.ttf", 42) self.keys = pygame.key.get_pressed() self.clock = pygame.time.Clock() self.register_eventhandler(pygame.QUIT, self.quit) self.register_key(pygame.K_ESCAPE, self.quit, singlepress = True) self.menu = MainMenu(self) self.pregame_menu = False self.betweengame_menu = False self.aftergame_menu = False Sound.sounds_init() Sound.Sounds["menumusic"].play() self.displaytime = False self.ammo = [] self.maps = ["grass", "sand"] if self.debug: self.displaytime = True
def __init__(self): pygame.mixer.pre_init(44100, -16, 2, 512) pygame.init() pygame.key.set_repeat(500, 100) pygame.font.init() pygame.event.set_allowed([ pygame.QUIT, pygame.VIDEORESIZE, pygame.KEYDOWN, pygame.MOUSEBUTTONDOWN ]) self.playing = True self.clock = pygame.time.Clock() self.running = True # Start with the game paused (menus will keep running though) self.paused = True self.fullscreen = config["graphics"]["fullscreen"] self.vsync = config["graphics"]["vsync"] # Engine self.renderer = Renderer(self) self.spriteRenderer = SpriteRenderer(self) self.clickManager = ClickManager(self) self.textHandler = TextHandler() # Loaders self.imageLoader = ImageLoader(self) self.mapLoader = MapLoader() self.audioLoader = AudioLoader() # Map editor self.mapEditor = MapEditor(self) # Menu's self.mainMenu = MainMenu(self) self.optionMenu = OptionMenu(self) if self.fullscreen: self.renderer.setFullscreen() self.setCaption() self.setIcon() self.setCursor()
def main(): start_menu = StartMenu() main_menu = MainMenu() mode = 'start' user = None while True: try: if mode == 'start': user = start_menu.start_logic() mode = 'registered' elif mode == 'registered': main_menu.main_menu_logic() mode = 'start' except UserExitException: print('\n\n=================================================\nExiting the programm.\nThank you for using this software and goodbye!') exit(0)
def __init__(self, window): self.window = window self.active_env = None self.levelone_env = self.init_levelone() self.main_menu_env = MainMenu(on_start_game=self.start_game, on_exit=self.exit, window=self.window) self.pause_env = PauseMenu(on_resume=self.start_game, on_restart=self.restart, on_exit=self.exit, window=self.window) self.game_over_env = GameOverMenu(on_restart=self.restart, on_exit=self.exit, window=self.window) self.start_menu()
def __init__(self, cfg, mic=None): # arguments self.cfg = cfg self.mic = mic # init pygame pygame.init() # init display self.screen = pygame.display.set_mode(self.cfg['game']['screen_size']) # screen capturer self.screen_capturer = ScreenCapturer(self.screen, self.cfg['game']) # menues self.main_menu = MainMenu(self.cfg['game'], self.screen) self.help_menu = HelpMenu(self.cfg['game'], self.screen) self.option_menu = OptionMenu(self.cfg['game'], self.screen, self.mic) # game loop self.game_loop_state_dict = { 'main_menu_loop': 0, 'game_loop': 1, 'help_menu_loop': 2, 'option_menu_loop': 3, 'exit': 4 } # loop action self.loop_action_dict = { 'start_button': 'game_loop', 'help_button': 'help_menu_loop', 'option_button': 'option_menu_loop', 'end_button': 'exit', 'exit': 'exit' } # start at main menu self.game_loop_state = self.game_loop_state_dict['main_menu_loop']
def __init__(self): wx.Frame.__init__(self, None, size=(600, 600), title="Astute Song Hunter", style=wx.DEFAULT_FRAME_STYLE & ~(wx.MAXIMIZE_BOX | wx.RESIZE_BORDER)) self.Menubar = MainMenu(self) self.SetMenuBar(self.Menubar) self.MainPanel = wx.Panel(self) self.Tools = Toolbar(self, self.MainPanel) self.Tune = TunePanel(self, self.MainPanel) self.Song = SongPanel(self, self.MainPanel) self.Search = SearchPanel(self, self.MainPanel) self.SetToolBar(self.Tools) VBox = wx.BoxSizer(wx.VERTICAL) VBox.Add(self.Tune, proportion=0, flag=wx.BOTTOM | wx.LEFT, border=10) VBox.Add(self.Search, proportion=0, flag=wx.LEFT | wx.TOP, border=20) HBox = wx.BoxSizer() HBox.Add(VBox, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) HBox.Add(self.Song, proportion=1, flag=wx.EXPAND | wx.ALL, border=5) self.MainPanel.SetSizer(HBox) self.Centre()
from machine import Pin, SoftI2C from sh1106 import SH1106, SH1106_I2C from menu import MainMenu from time import sleep from time import time import config # # Create Display # i2c: SoftI2C = SoftI2C(scl=Pin(22), sda=Pin(21), freq=400000) config.DISPLAY = SH1106_I2C(128, 64, i2c, addr=0x3c) config.DISPLAY.sleep(False) # # Create Menu # config.MAIN_MENU = MainMenu(config.DISPLAY) # Updates values on main menu config.delay(config.delay()) config.blob(config.blob()) config.active(config.active()) # Impoprt pin listeners import pinListener
return index - 1 return 0 return index def save_log(self): """Saves all tasks in a csvfile.""" with open(self.file, 'w') as csvfile: fieldnames = ["Date", "Title", "Time", "Notes"] writer = csv.DictWriter(csvfile, fieldnames=fieldnames) writer.writeheader() for entry in self.TASKS: writer.writerow(entry.log()) def add_task(self): """ Let the user to create and add a new task to the log. Once is created, the file is saved and the user is prompted with the new task to review its content. Tasks are sorted before being saved to file to keep them ordered. """ task = Task() self.TASKS.append(task) self.sort_tasks(self.TASKS) self.save_log() task.show() input("The entry has been added. Press enter to return to the menu") if __name__ == '__main__': MainMenu(WorkLog('log.csv')).run()
"""Add new entry""" employee, _ = models.Employee.get_or_create(name=utils.get_name()) task = models.Task.create(employee=employee, title=utils.get_title(), time=utils.get_time(), notes=utils.get_notes()) task.show() input("The entry has been added. Press enter to return to the menu") @classmethod def edit_task(self, index, tasks): """Edit entry""" tasks[index].edit() return index @classmethod def delete_task(self, index, tasks): """Delete a task for the user selected.""" answer = input("Do you really want to delete this task? [y/N]: ") if answer.lower() == 'y': tasks[index].delete_instance() tasks.remove(tasks[index]) if index > 1: return index - 1 return 0 return index if __name__ == '__main__': MainMenu().run()
""" This module initializes and runs the main game. """ from game import Game from menu import MainMenu import pygame SCREEN_SIZE = (960, 500) if __name__ == "__main__": pygame.init() pygame.display.set_caption("PING") goal_score = 10 game = Game(SCREEN_SIZE, goal_score) mainMenu = MainMenu(game, SCREEN_SIZE) mainMenu.display()
def set_menu_mode(self): self.mode = self.Mode.MENU self.menu = MainMenu(main=self, screen=self.display, settings=self.settings)
def run_main(): menu_scene = Scene() menu_scene.add(BackgroundLayer()) menu_scene.add(MultiplexLayer(MainMenu(), Authors())) director.run(menu_scene)
from menu import MainMenu menu = MainMenu() menu.run()
def main(): storage = Storage() storage.fill_storage() main_menu = MainMenu() main_menu.show()