def main(): """ Walk CODE directory to locate PyLauncher.json files. Once located, import data and generate menu items and CMD objects to execute commands when selected. """ selections = [] for root, _dirs, files in os.walk(CODE): # If JSON file is found, read data if 'PyLauncher.json' in files: with open(Path(root) / 'Pylauncher.json', 'r') as json_file: jdata = json.loads(json_file.read()) # Use JSON data to generate menu items and CMD objects selections.append((jdata['Display Info'], CMD( jdata['Project Folder'], jdata['Script Path'], jdata['Env Folder']))) # Add an exit option to the end of the list selections.append(('[ Exit ]', CMD('EXIT', '', ''))) # Display menu and call commands on selection title.show() menu.display(*selections).send_commands()
def validate_data(): login_data = login.get() password_data = password.get() if login == '' or password == '': messagebox.showinfo( "Minesweeper Game", 'Name and Password fields should not be empty !') elif len(password_data) < 5: messagebox.showinfo( "Minesweeper Game", 'Password should be longer then 5 characters !') else: sqlite3_connect_db.cursor.execute( "SELECT * FROM users WHERE login = ? ", (login_data, )) rows = sqlite3_connect_db.cursor.fetchall() if rows: if rows[0][0] == login_data and rows[0][1] == password_data: root.destroy() game.username = login_data menu.display() else: messagebox.showinfo("Minesweeper Game", 'Incorrect login or password !') else: messagebox.showinfo("Minesweeper Game", 'Cant find account with this login !')
def game_menu(): global screen,background,title,clock menu.buttons = ['new_game.png','exit.png'] menu.hotspots = [(200,410),(510,410)] menu.actions = ['new_game','exit'] menu.direction = "horizontal" menu.position = (400,400) gfx.screen.blit(background,(0,0)) gfx.screen.blit(title,(120,20)) pygame.display.flip() return menu.display()
def buildEnd(bg, character, name, quote): gameDisplay.blit(bg, (0, 0)) gameDisplay.blit(character.image(), (displayWidth * 0.1, displayHeight * 0.7)) pygame.draw.rect(gameDisplay, red, [ displayWidth * 0.2, displayHeight * 0.05, displayWidth * 0.6, displayHeight * 0.5 ]) menu.display('GAME OVER', displayWidth * 0.25, displayHeight * 0.1, 100) xQuotes = displayWidth / 2 - (len(quote) * 14 / 2) menu.display(quote, xQuotes, displayHeight * 0.28, 40) menu.display(f'Your score was {character.score}', displayWidth * 0.37, displayHeight * 0.35, 35) menu.display('Enter Name:', displayWidth * 0.4, displayHeight * 0.45, 30) menu.display(name, displayWidth * 0.55, displayHeight * 0.45, 30)
def listening_loop(): while 1: # if not api.requests_to_send.empty(): send = True try: req = api.requests_to_send.get(False) except queue.Empty: send = False #print("queue empty") if send: #print("request queue not empty") req_body_str = req.getBodyString() main_socket.send(bytes(req_body_str, "UTF-8")) #print("sent", req_body_str) api.sent_requests.append(req) #handle the info ready = select.select([main_socket], [], [], 0.5) if ready[0]: data = main_socket.recv(2048) data = str(data, encoding='UTF-8') api.handle_server_response(repr(data)) #print('Received', repr(data)) listening_thread = threading.Thread(target=listening_loop, args=()) listening_thread.start() while 1: menu.display()
q = menu.Item(0, 0) menu = menu.Menu().fromxml(e) config = config.Config("system.conf") #config.showall() #exit() #menu.rprint() device = lcdui.lcd(0x27, 1, True, False) while True: a = menu.display() for (idx, val) in enumerate(a): device.lcd_puts(val, idx + 1) #device.lcd_puts(" Tilbage ",2); #device.lcd_puts("* Statistik ",3); #device.lcd_puts(" Netvaerk ",4); print "" menu.rprint() a = readchar.readchar() if a == 'o': q = -1 elif a == 'k': q = 0 elif a == 'm': q = 1 elif a == 'q': exit() else: continue if (menu.execute(q) == -10): exit()
api.use_socket(main_socket) def listening_loop(): while 1: # if not api.requests_to_send.empty(): send = True try: req = api.requests_to_send.get(False) except queue.Empty: send=False #print("queue empty") if send: #print("request queue not empty") req_body_str = req.getBodyString() main_socket.send(bytes(req_body_str, "UTF-8")) #print("sent", req_body_str) api.sent_requests.append(req) #handle the info ready = select.select([main_socket], [], [], 0.5) if ready[0]: data = main_socket.recv(2048) data = str(data, encoding='UTF-8') api.handle_server_response(repr(data)) #print('Received', repr(data)) listening_thread = threading.Thread(target=listening_loop, args=() ) listening_thread.start() while 1: menu.display()