示例#1
0
 def load_map(self):
     """Loads a map from a JSON-formatted file."""
     # Prompt user for the map file to open
     map_file = easygui.fileopenbox("Select the map file to open.")
     # Stop and return to start if user canceled/closed the window
     if map_file == None:
         return
     # Open the file and process the JSON data
     with open(map_file, 'r') as f:
         json_data = None
         try:
             # Load file's JSON data into python objects
             json_data = json.loads(f.read())
             # Load tile map
             self.common.tile_map = json_data['tile_map']
             # Create generator with the loaded map's parameters
             self.MapGen = genmap.MapGenerator(self.common, json_data['generator_data'])
             # Switch to map edit phase
             self.common.edit_phase = True
         # JSON could not load data from the file or it is not correctly formatted
         except (ValueError, KeyError):
             # Display info to user
             msg = "\"{name}\" is not a valid GenEditor JSON formatted map file.".format(
                 name=os.path.basename(map_file)
                 )
             easygui.msgbox(msg, "Invalid Map")
         finally:
             # Clear JSON data to save memory
             del json_data
示例#2
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"

#prints the whole argument line
示例#3
0
     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:
             dictionary_file_path=""
     elif re.search("Help",__mode__) is not None:
         dictionary_of_work=dictionary.dictionary()
         dictionary_of_work.help()
     elif re.search("Quit",__mode__) is not None:
         __mode__=None
 
 __number_of_word_to_learn_by_serie__=20
 __day_in_advance__=0
 while not __mode__==None:
     
示例#4
0
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