def save_map(self): """Writes the map data to a text file and image file.""" # Prompt for the save location save_path = easygui.filesavebox("Two files will be created, one image and one text file.") # User cancels the save operation if save_path is None: return # Get a complete rendering of the map img = self.GFX.render_full_map() # Check if that is already a file(s) with that name(s), and if it ok to override it msg = "There is already a file in this location with that name. Override?" if (os.path.exists(save_path+".bmp") or os.path.exists(save_path+".json")) and easygui.buttonbox(msg, "Continue?", ("Yes", "No")) == "No": return # Otherwise save the map files else: # Save image to file pygame.image.save(img, save_path + ".bmp") # Save map data as JSON data with open(save_path + ".json", 'w') as f: json.dump({'generator_data' : self.MapGen.params, 'tile_map' : self.common.tile_map}, f) # Indicate saving is complete easygui.msgbox("\"" + str(os.path.basename(save_path)) + "\" saved successfully", "Save Complete")
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 print 'The whole command: ' + params #launches mid2cnc with the argument string os.system ('python -i mid2cnc.py ' + params)
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: dictionary_file_path="" elif re.search("Help",__mode__) is not None: dictionary_of_work=dictionary.dictionary() dictionary_of_work.help()
#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 print 'The whole command: ' + params