def __init__(self): # Load our handler self.handler = Handler.Handler(self) self.handler.load() # Show Menu self.menu = Menu.Menu(self) self.menu.load() # Hold the program self.exit()
def __init__(self): # Load our handler self.handler = Handler.Handler(self) self.handler.load() # Generate rounds self.handler.generate_rounds() # Show Menu self.menu = Menu.Menu(self) # Hold the program self.exit()
def main(stdscr): #initialization menu = Menu(stdscr, 'Help', 'Play', 'Stats', 'Exit') keyboard = Keyboard(stdscr) database = Database(stdscr) mode = 0 key = 0 curses.curs_set(0) curses.noecho() curses.use_default_colors() #selct mode based on menu options while mode != 4: #menu mode if mode == 0: stdscr.clear() menu.print_splash() menu.print_menu() mode = menu.navigate(stdscr.getch()) stdscr.refresh() #help mode elif mode == 1: help_string = ''' Welcome to termtype! Termtype is a touch-typing aid that allows you to practice your skills by typing random Wikipedia articles. Simply type the displayed text, and refer to the line above to check which finger to use. From left pinky to right pinky, the fingers are numbered 1-8, with thumbs omitted. Press enter to remove typed words from the display, and press escape at any time to stop typing. Your typed words will still count towards your progress even if you don't finish the article, so feel free to stop at anytime! For more information, visit https://github.com/bajaco/termtype Press any key to continue: ''' help_formatter = Formatter(stdscr, help_string) stdscr.clear() help_formatter.print_text() c = stdscr.getch() mode = 0 #play mode elif mode == 2: #initialization for play mode wiki = Wiki() typing_buffer = Buffer() page_text = wiki.get_page() guide_text = keyboard.transform_text(page_text) error_text = '' errors = 0 entered_words = 0 timer = Timer() #Formatter for article wiki_formatter = Formatter(stdscr, page_text, line_height=6, vertical_offset=1, vertical_buffer=0) #Formatter for finger indication guide_formatter = Formatter(stdscr, guide_text, line_height=6, vertical_offset=0, vertical_buffer=0) #Formatter for typed text typing_formatter = Formatter(stdscr, typing_buffer.get_text(), line_height=6, vertical_offset=2, vertical_buffer=0) #Formatter for error text error_formatter = Formatter(stdscr, error_text, line_height=6, vertical_offset=3, vertical_buffer=0) #gameplay loop while (True): #clear string and print from formatters stdscr.clear() wiki_formatter.print_text() guide_formatter.print_text() typing_formatter.print_text() error_formatter.print_text() #break if there are no more words to be typed and show statistics if wiki_formatter.out_of_words(): timer.stop() break #if key is enter, remove page from wiki and guide formatters stdscr.refresh() c = stdscr.getch() #if key is ENTER if c == 10: count = typing_buffer.get_count() entered_words += count removed = wiki_formatter.remove_words(count) guide_formatter.remove_words(count) errors += typing_buffer.new_errors(removed) typing_buffer.clear() error_formatter.set_master('') typing_formatter.set_master('') #if key is ESC elif c == 27: count = typing_buffer.get_count() entered_words += count if entered_words == 0: break timer.stop() removed = wiki_formatter.remove_words(count) guide_formatter.remove_words(count) errors += typing_buffer.new_errors(removed) break #other keys else: #start timing if necessary if not timer.is_timing(): timer.start() typing_buffer.input(c, keyboard) typing_formatter.set_master(typing_buffer.get_text()) error_formatter.set_master( keyboard.error_text(wiki_formatter.dump_text(), typing_buffer.get_text())) #statistics loop while (True): if entered_words == 0: mode = 0 break stdscr.clear() database.write(timer.get_duration(), entered_words, errors) database.read() database.print_stats() stdscr.refresh() c = stdscr.getkey() if c == 'q': mode = 4 break else: mode = 0 break #stats mode elif mode == 3: while (True): stdscr.clear() database.read() database.print_stats() stdscr.refresh() c = stdscr.getkey() if c == 'q': mode = 4 break else: mode = 0 break
import datetime import pymysql import schedule import time from pymysql.cursors import DictCursor from classes import TelegramBot, Menu, MainMenu, Game, Booking, Information, Newsletter from random import shuffle from telebot import * from multiprocessing.context import Process telegram_bot = TelegramBot() menu_bot = Menu() main_menu_bot = MainMenu() booking_bot = Booking() information_bot = Information() newsletter = Newsletter() game_bot = Game() qNum = 0 correct_answer = '' question = '' score = 0 isGame = False isBooking = False bot = telegram_bot.bot booking_date, date_time, free_tables, questions = (0, 0, [], 0)
def menu(display, settings): """This function creates a menu object, watches for input, and then returns an int based on the input""" if settings.settings["Music"] == "On": pygame.mixer.music.load('assets/main_menu.wav') # params: -1 plays the music indefinitely; 5 plays it once and then loops 5 times = 6 times pygame.mixer.music.play(-1) m = Menu(display, settings) centre = (settings.settings["Resolution"]["X"] / 2, settings.settings["Resolution"]["Y"] / 2) stars = [ Starfield(settings.settings["Resolution"]["X"], settings.settings["Resolution"]["Y"]) for i in range(250) ] while True: display.fill(colour.black) m.draw() for star in stars: if star.x > settings.settings["Resolution"]["X"] or star.x < 0: stars.remove(star) new_star = Starfield(settings.settings["Resolution"]["X"], settings.settings["Resolution"]["Y"]) stars.append(new_star) elif star.y > settings.settings["Resolution"]["Y"] or star.y < 0: stars.remove(star) new_star = Starfield(settings.settings["Resolution"]["X"], settings.settings["Resolution"]["Y"]) stars.append(new_star) star.draw(display, centre) pygame.display.update() for event in pygame.event.get(): if event.type == pygame.QUIT: terminate() if event.type == pygame.MOUSEBUTTONDOWN and ( (200, 200) < pygame.mouse.get_pos() < (400, 400)): # Start m.destroy(display) m.draw("clicked", "unclicked", "unclicked") pygame.display.update() pygame.time.delay(750) return 1 elif event.type == pygame.MOUSEBUTTONDOWN and ( (600, 200) < pygame.mouse.get_pos() < (800, 400)): # Quit m.destroy(display) m.draw("unclicked", "clicked", "unclicked") pygame.display.update() return 0 elif event.type == pygame.MOUSEBUTTONDOWN and ( (400, 600) < pygame.mouse.get_pos() < (600, 800)): # Music toggle m.draw("unclicked", "unclicked", "clicked") pygame.display.update() if settings.settings["Music"] == "On": settings.settings["Music"] = "Off" pygame.mixer.music.stop() else: settings.settings["Music"] = "On" pygame.mixer.music.play(-1) pygame.time.delay(250) m.draw() pygame.display.update()
#!/usr/bin/python from classes import Menu, Gui import os, sys #create menu object menu = Menu() #give user sys args options - load gui or help then into terminal or just into terminal with no args if "--help" in sys.argv: input( "\nSee the help file in the menu for more information about the application \n\n" "Using --gui will launch the gui front end instead\nUsage: python main.py --gui \n\n- Press enter" ) if '--gui' in sys.argv: Gui.make_gui() #calls menu object menu.menu()