Example #1
0
    def modify_word(self,word_to_change=None):
        
        if word_to_change==None:
            choices_list=[]
            for word in self.__content.keys():
                choices_list.append(word)
            if len(choices_list)>0:
                word_to_change=easygui.choicebox(msg='Pick the item that you want to change', title='Change a Word', choices=choices_list)
        
        if not word_to_change==None:
            previous_translation=self.__content[word_to_change]["Definition/Translation/Association"]
            previous_group=str(self.__content[word_to_change]["Group"])
            input_modif=easygui.multenterbox(msg='Enter the new definition for the word: '+word_to_change,fields=("Word","Translation","Group"),values=(word_to_change,str(previous_translation),previous_group))
            if not input_modif==None:
                if input_modif[0]==word_to_change:
                    self.__content[word_to_change]["Definition/Translation/Association"]=input_modif[1]
                    self.__content[word_to_change]["Group"]=int(input_modif[2])
                else :
                    del self.__content[word_to_change]
                    word=input_modif[0]
                    translation=input_modif[1]
                    """Group=int(input_modif[2])"""
                    Group=0
                    Last_Interogation_Date=None
                    Time_since_the_last_interogation=None
                    Time_before_the_next_interogation=0

                    self.__content[word]={"Word":word,"Definition/Translation/Association":translation,"Group":Group,
                                          "Last Interogation Date":Last_Interogation_Date,
                                          "Number of Days since the last interogation":Time_since_the_last_interogation,
                                          "Number of Days before the next interogation":Time_before_the_next_interogation}
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 
Example #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
Example #4
0
            for file_name in os.listdir(os.getcwd()+"/dictionary/"+user+"/"+language):
                if re.search("^[.]",file_name) is None:
                    dictionary_file_path=os.getcwd()+"/dictionary/"+user+"/"+language+"/"+file_name
                    dictionary_of_work=dictionary.dictionary()
                    dictionary_of_work.upload_dictionary(dictionary_file_path)

    __mode__=""
    while dictionary_file_path=="" and not __mode__==None:
    
        msg     = "Welcome in Vocable.\nWhat do you want to do?"
        title   = "VocablePython"
        choices = ["01-           Create a Dictionary",
        "02-           Load a Dictionary",
        "03-           Help",
        "04-           Quit"]
        __mode__   = easygui.choicebox(msg, title, choices)
        if __mode__==None:
            pass
        elif re.search("Create a Dictionary",__mode__) is not None:
            dictionary_file_path=easygui.filesavebox(default="dictionary_name.csv")
            if not dictionary_file_path== None:
               dictionary_of_work=dictionary.dictionary()
               dictionary_of_work.save(dictionary_file_path)
            else:
                dictionary_file_path=""
        elif re.search("Load a Dictionary",__mode__) is not None:
             dictionary_file_path=easygui.fileopenbox(msg="Select The Dictionary you want to use",title="Dictionary Selection")
             if not dictionary_file_path== None:
                 dictionary_of_work=dictionary.dictionary()
                 dictionary_of_work.upload_dictionary(dictionary_file_path)
             else:
Example #5
0
#Syntax to pass to the mid2cnc script: params = '-outfile ./mytest.gcode'
# Prints are here just to show the user what's happeneing. They might as be removed.

import os
import lib.easygui as eg
params = '' #initializing variable. This is the argument string that we will pass to Mid2CNC

machinelist = ('ultimaker', 'cupcake', 'thingomatic', 'shapercube', 'custom') #Creates a list of entries
machine = eg.choicebox(msg='Machine type', title='Pick machine', choices=machinelist) #Creates a GUI Window for a choice in the machine list
print 'Chosen machine :' + machine #What the user chose

params = params + ' --machine ' + machine #add that choice to the parameter string
#Same pattern for the other options

#Ask what MIDI input file to open
infile = eg.fileopenbox(msg='Choose the midi file ', title=' Grab the file you want to convert', default=os.path.expanduser("~")+ "//My Documents//", filetypes = "*.mid") # the "default=os.path.expanduser("~")" gets your home forlder so you don't have top start browsing from some obscure python install folder
print 'Opening file: ' + infile
params = params + ' --infile ' + infile

#asks where to save the output gcode file
#for some reason this window sometimes appears behind all others
outfile = eg.filesavebox(msg='Choose the output file ', title=' Pick where you want the gcode to arrive', default=os.path.expanduser("~")+"//My Documents//Output.gcode", filetypes = "*.gcode")
print 'Saving to: ' +  outfile
params = params + " --outfile " +  outfile

#ask if the verbose should be activated
verbose = eg.boolbox(msg='Do you want the verbose to be activated (for debug)', title=' Verbose Y/N ', choices=('No', 'Yes'), image=None) # returns true if the first is chosen
if verbose == 0:
	 params = params + " --verbose"
#Syntax to pass to the mid2cnc script: params = '-outfile ./mytest.gcode'
# Prints are here just to show the user what's happeneing. They might as be removed.

import os
import lib.easygui as eg
params = ''  #initializing variable. This is the argument string that we will pass to Mid2CNC

machinelist = ('ultimaker', 'cupcake', 'thingomatic', 'shapercube', 'custom'
               )  #Creates a list of entries
machine = eg.choicebox(
    msg='Machine type', title='Pick machine', choices=machinelist
)  #Creates a GUI Window for a choice in the machine list
print 'Chosen machine :' + machine  #What the user chose

params = params + ' --machine ' + machine  #add that choice to the parameter string
#Same pattern for the other options

#Ask what MIDI input file to open
infile = eg.fileopenbox(
    msg='Choose the midi file ',
    title=' Grab the file you want to convert',
    default=os.path.expanduser("~") + "//My Documents//",
    filetypes="*.mid"
)  # the "default=os.path.expanduser("~")" gets your home forlder so you don't have top start browsing from some obscure python install folder
print 'Opening file: ' + infile
params = params + ' --infile ' + infile

#asks where to save the output gcode file
#for some reason this window sometimes appears behind all others
outfile = eg.filesavebox(msg='Choose the output file ',
                         title=' Pick where you want the gcode to arrive',
Example #7
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