def gamemenu():
    # setting directory for stroing highscorelist / logfile 
    #~ means home on linux . as first char will hide 
    gamefolder =  os.path.expanduser(os.path.join("~",".screensavertest"))  
    gamefile = os.path.join(gamefolder, "highscorelist.txt")                   
    # do not name gamefile "file", that is a reserved word !
    createGameDir(gamefolder)
    createGameFile(gamefile)
    # gamefile should now exist in gamefolder
    resolution = [640,480]
    fullscreen = False
    watched = 0
    title = "please choose wisely:"
    buttons = ["watch screensaver", "change resolution", "toggle fullscreen", "view highscore","visit homepage", "quit"]
    #picture = None # gif file or make sure python-imaging-tk is installed correctly
    picture = "data/tux.gif" 
    # ---- use pygame only to get a list of valid screen resolutions ---
    reslist = getPygameModes()
    # --- ask player name ----
    playername = easygui.enterbox("What is you name?", "please enter you name and press ENTER or click ok", "Mister dunno")

    while True: #endless loop        
        if fullscreen:
            msg2 = "fullscreen mode"
        else:
            msg2 = "window mode"
        msg = "Welcome at screensaver game menu.\nScreensaver will run with %ix%i resolution,\n%s" % (resolution[0], resolution[1], msg2)
        selection = easygui.buttonbox(msg, title, buttons, picture)
        if selection == "quit":
            easygui.msgbox("bye-bye", "such a sad decision...")
            break # leave loop
        elif selection == "visit homepage":
            print("i try to open the webbrowser, please wait a bit...")
            webbrowser.open_new_tab("http://www.thepythongamebook.com")
        elif selection == "toggle fullscreen":
            fullscreen = not fullscreen 
        elif selection == "view highscore":
            text = readGameFile(gamefile)
            easygui.textbox("This is the Screensaver logfile", "displaying highscore", text)
        elif selection == "watch screensaver":
            watched += 1
            # get return value from called pygame program (playtime)
            playtime = screensaver.screensaver(resolution, fullscreen)
            easygui.msgbox("You watched the scrensaver %i x using this game menu \nYour screen was saved for %.2f seconds" % (watched, playtime))
            # writing highscore-list
            line = "date: %s player: %s playtime:  %.2f seconds resolution: %ix%i fullscreen: %s \n" % (time.asctime(), playername, playtime, resolution[0], resolution[1], fullscreen)
            writeGameFile(gamefile, line)
        elif selection == "change resolution":
            answer = easygui.choicebox("Please select one of those screen resolutions", "x,y", reslist)
            # answer gives back a string like '(320, 200)'
            resolution = parse(answer)
            
    return 
Esempio n. 2
0
    def help(self):
        text_to_display='''Welcome in PythonVocable!\n
        This tool has been designed to allow people to enhance their vocabulary a foreign Language
        using the FlashCards and the LEITNER Method
        Creator: Kevin DUIGOU. Release: 19 November 2012. Version: 2.0\n\n\n'''
        text_to_display+='''### Flash Card ###\n        A flashcard or flash card is a set of cards bearing information,
        as words or numbers, on either or both sides, used in classroom drills or in private study. 
        One writes a question on a card and an answer overleaf. 
        Flashcards can bear vocabulary, historical dates, 
        formulas or any subject matter that can be learned via a question and answer format. 
        Flashcards are widely used as a learning drill to aid memorization by way of spaced repetition.\n\n\n'''
        text_to_display+='''### The LEITNER Method ###\n        The Leitner system is a widely used method to efficiently use flashcards that was proposed 
        by the German science journalist Sebastian Leitner in the 1970s.
        It is a simple implementation of the principle of spaced repetition,
        where cards are reviewed at increasing interval.

        In this method flashcards are sorted into groups according to how well you know each one
        in the Leitner's learning box. This is how it works: you try to recall the solution written on a flashcard.
        If you succeed, you send the card to the next group.
        But if you fail, you send it back to the first group.
        Each succeeding group has a longer period of time before you are required to revisit the cards.'''
        easygui.textbox(title='HELP', text=text_to_display, codebox=0)
Esempio n. 3
0
def gamemenu():
    gamefolder = os.path.expanduser(os.path.join(
        "~",
        ".screensavertest"))  # ~ means home on linux . as first char will hide
    gamefile = os.path.join(
        gamefolder, "highscorelist.txt"
    )  # do not call it "file", that is a reserved word !
    if os.path.isdir(gamefolder):
        print "directory already exist"
    else:
        print "directory does not exist yet"
        try:
            os.mkdir(gamefolder)
        except:
            raise UserWarning, "error at creating directory %s" % gamefolder
            exit()
    if os.path.isfile(gamefile):
        print "highscore file aready exist"
    else:
        try:
            f = file(gamefile, "w")  # open for writing
            f.write("--- screensaver logfile ---\n")
            f.close()
        except:
            raise UserWarning, "error while creating file %s" % gamefile
            exit()
    # gamefile should now exist in gamefolder

    resolution = [640, 480]
    fullscreen = False
    watched = 0
    title = "please choose wisely:"
    buttons = [
        "watch screensaver", "change resolution", "toggle fullscreen",
        "view highscore", "quit"
    ]
    #picture = None # gif file or make sure python-imaging-tk is installed correctly
    picture = "data/tux.gif"
    # ---- use pygame only to get a list of valid screen resolutions ---
    pygame.init()
    reslist = pygame.display.list_modes()
    pygame.quit()
    # ---- end of pygame ----------
    # --- ask player name ----
    playername = easygui.enterbox(
        "What is you name?",
        "please enter you name and press ENTER or click ok", "Mister dunno")
    while True:  #endless loop

        if fullscreen:
            msg = "Welcome at screensaver game menu.\nScreensaver will run with %ix%i resolution,\nfullscreen mode" % (
                resolution[0], resolution[1])
        else:
            msg = "Welcome at screensaver game menu.\nScreensave will run with %ix%i resolution,\nwindow mode" % (
                resolution[0], resolution[1])
        selection = easygui.buttonbox(msg, title, buttons, picture)
        if selection == "quit":
            easygui.msgbox("bye-bye", "such a sad decision...")
            break  # leave loop
        elif selection == "toggle fullscreen":
            fullscreen = not fullscreen
        elif selection == "view highscore":
            try:
                f = file(gamefile, "r")  # read
                text = f.read()
                f.close()
            except:
                raise UserWarning, "Error while reading higscore file %s" % gamefile
                exit()
            easygui.textbox("This is the Screensaver logfile",
                            "displaying highscore", text)
        elif selection == "watch screensaver":
            watched += 1
            playtime = screensaver.screensaver(resolution, fullscreen)
            easygui.msgbox(
                "You watched the scrensaver %i x using this game menu \nYour screen was saved for %.2f seconds"
                % (watched, playtime))
            # writing highscore-list
            try:
                f = file(gamefile, "a")  # append
                f.write(
                    "date: %s player: %s playtime:  %.2f seconds resolution: %ix%i fullscreen: %s \n"
                    % (time.asctime(), playername, playtime, resolution[0],
                       resolution[1], fullscreen))
                f.close()
            except:
                raise UserWarning, "Error while writing higscore file %s" % gamefile
                exit()
        elif selection == "change resolution":
            answer = easygui.choicebox(
                "Please select one of those screen resolutions", "x,y",
                reslist)
            # answer gives back a string like '(320, 200)'
            comma = answer.find(",")  # position of the comma inside answer
            x = int(answer[1:comma])
            y = int(answer[comma + 1:-1])
            resolution = (x, y)
    return
Esempio n. 4
0
    def stat_display (self):
        number_total_of_word=len(self.__content.keys())
        Group_stat={}
        Group_list=[]
        time_before_interogation={}
        time_before_interogation_list=[]


        average_group=0

        text_to_display="##########   STAT   ##########\n"
        text_to_display+="Number of Word in the Dictionary: "+str(number_total_of_word)+"\n"

        for french_word, word_value in self.__content.items():
            Group=int(word_value["Group"])
            average_group+=Group
            if not int(word_value["Group"])==0:
                days_before_interogation=fibonacci.fib(int(word_value["Group"]))-int(word_value["Number of Days since the last interogation"])
            else :
                days_before_interogation=0
            if days_before_interogation<0:
                days_before_interogation=0

            days_before_interogation_list=[]

            if not Group in Group_stat.keys():
                Group_stat[Group]=1
                Group_list.append(Group)
            else:
                Group_stat[Group]+=1
            if not days_before_interogation in time_before_interogation.keys():
                time_before_interogation[days_before_interogation]=1
                time_before_interogation_list.append(days_before_interogation)
            else:
                time_before_interogation[days_before_interogation]+=1
        
        if not number_total_of_word==0:
            average_group=average_group/number_total_of_word
            text_to_display+="Average Group: "+str(average_group)+"\n"
        

        text_to_display+="_____________________________________________\n"
        

        time_before_interogation_list.sort()
        Group_list.sort()


        for Group in Group_list:
            number_of_word=Group_stat[Group]
            text_to_display+="Per Cent of Word in Group "+str(Group)+": "+str(number_of_word*100/number_total_of_word)+"("+str(number_of_word)+" Words)"+"\n"
        text_to_display+="_____________________________________________\n"

        text_to_display+="_____________________________________________\n"
        
        for number_of_days in time_before_interogation_list:
            number_of_word=time_before_interogation[number_of_days]
            text_to_display+=str(number_of_word)+" more Words will be present in the interogation set in "+str(number_of_days)+" Days\n"
        text_to_display+="_____________________________________________\n"

        text_to_display+="##########   END STAT   ##########\n"
        easygui.textbox(title='Statistic', text=text_to_display, codebox=0)
Esempio n. 5
0
def gamemenu():
    gamefolder =  os.path.expanduser(os.path.join("~",".screensavertest"))  # ~ means home on linux . as first char will hide 
    gamefile = os.path.join(gamefolder, "highscorelist.txt")                    # do not call it "file", that is a reserved word !
    if os.path.isdir(gamefolder):
        print "directory already exist"
    else:
        print "directory does not exist yet"
        try:
            os.mkdir(gamefolder)
        except:
            raise UserWarning, "error at creating directory %s" % gamefolder
            exit()
    if os.path.isfile(gamefile):
        print "highscore file aready exist"
    else:
        try:
            f = file(gamefile, "w") # open for writing
            f.write("--- screensaver logfile ---\n")
            f.close()
        except:
            raise UserWarning, "error while creating file %s" % gamefile
            exit()
    # gamefile should now exist in gamefolder
    
        
    resolution = [640,480]
    fullscreen = False
    watched = 0
    title = "please choose wisely:"
    buttons = ["watch screensaver", "change resolution", "toggle fullscreen", "view highscore", "quit"]
    #picture = None # gif file or make sure python-imaging-tk is installed correctly
    picture = "data/tux.gif" 
    # ---- use pygame only to get a list of valid screen resolutions ---
    pygame.init()
    reslist = pygame.display.list_modes()
    pygame.quit()
    # ---- end of pygame ----------
    # --- ask player name ----
    playername = easygui.enterbox("What is you name?", "please enter you name and press ENTER or click ok", "Mister dunno")
    while True: #endless loop
        
        if fullscreen:
            msg = "Welcome at screensaver game menu.\nScreensaver will run with %ix%i resolution,\nfullscreen mode" % (resolution[0], resolution[1])
        else:
            msg = "Welcome at screensaver game menu.\nScreensave will run with %ix%i resolution,\nwindow mode" % (resolution[0], resolution[1])
        selection = easygui.buttonbox(msg, title, buttons, picture)
        if selection == "quit":
            easygui.msgbox("bye-bye", "such a sad decision...")
            break # leave loop
        elif selection == "toggle fullscreen":
            fullscreen = not fullscreen 
        elif selection == "view highscore":
            try:
                f = file(gamefile, "r") # read
                text = f.read() 
                f.close()
            except:
                raise UserWarning, "Error while reading higscore file %s" % gamefile
                exit()
            easygui.textbox("This is the Screensaver logfile", "displaying highscore", text)
        elif selection == "watch screensaver":
            watched += 1
            playtime = screensaver.screensaver(resolution, fullscreen)
            easygui.msgbox("You watched the scrensaver %i x using this game menu \nYour screen was saved for %.2f seconds" % (watched, playtime))
            # writing highscore-list
            try:
                f = file(gamefile, "a") # append
                f.write("date: %s player: %s playtime:  %.2f seconds resolution: %ix%i fullscreen: %s \n" % (time.asctime(), playername, playtime, resolution[0], resolution[1], fullscreen))
                f.close()
            except:
                raise UserWarning, "Error while writing higscore file %s" % gamefile
                exit()
        elif selection == "change resolution":
            answer = easygui.choicebox("Please select one of those screen resolutions", "x,y", reslist)
            # answer gives back a string like '(320, 200)'
            comma = answer.find(",") # position of the comma inside answer
            x = int(answer[1:comma])
            y = int(answer[comma+1:-1])
            resolution = (x,y)
    return