def save_command(): file = tkFileDialog.asksaveasfile(mode='w') if file != None: # slice off the last character from get, as an extra return is added data = txt.get('1.0', END+'-1c') file.write(data) file.close()
def saveconfig(self): #get all values from widgets in frames above config_str = [ self.inputstr.get(), self.typestr.get(), self.polaritystr.get(), self.resistancestr.get(), self.modestr.get(), self.maxcurrentstr.get(), self.powerupvar.get(), self.maxuserstr.get(), self.heateroutputstr.get(), self.pstr.get(), self.istr.get(), self.dstr.get(), self.setptstr.get(), self.setptrampvar.get(), self.setptratestr.get() ] today = datetime.date.today().strftime('%Y%m%d') config_name = 'heater_%d_%s' % (self.ID, today) f = tkFileDialog.asksaveasfile(mode='w', initialdir='heater_config', initialfile=config_name, defaultextension='.dat') for str_elem in config_str: f.write('%s\n' % str_elem) return None
def savemd(): """get a filename and save the text in the editor widget""" # default extension is optional, here will add .txt if missing md = tkFileDialog.asksaveasfile(mode='w', defaultextension=".md") text2save = str(text2.get(0.0,END)) md.write(text2save) md.close()
def save_file(self): fileToSave = tkFileDialog.asksaveasfile(mode='w', defaultextension = ".txt") text2save = [] other_acts=[] for period in range(12): text2save.append([]) for group in range(len(self.groups)): if self.groups[group].get_schedule()[period] in self.activities: text2save[period].append(self.activities.index(self.groups[group].get_schedule()[period])) else: o_act = self.groups[group].get_schedule()[period] other_acts.append([o_act.get_name(), o_act.get_min_age(), o_act.get_max_age(), o_act.get_competing_activity(), o_act.not_days, [self.activities.index(o_act.other_act[0]), self.activities.index(o_act.other_act[1])]]) text2save[period].append(100) activity_list = [] for act in self.activities: if type(act.get_competing_activity()) == type(None): activity_list.append([act.get_name(), act.get_min_age(), act.get_max_age(), act.get_competing_activity(), act.not_days]) else: comp_act = self.activities.index(act.get_competing_activity()) activity_list.append([act.get_name(), act.get_min_age(), act.get_max_age(), comp_act, act.not_days]) fileToSave.write(str([text2save,activity_list, other_acts])) fileToSave.close()
def save_config(self): f = tkFileDialog.asksaveasfile(mode='w', title="Save Configurations As...") if f: config = ConfigParser.RawConfigParser() config.add_section("MAIN") config.set("MAIN", "NUMBER_OF_PVS", str(len(self.pvs))) i = 0 for pv in self.pvs: index = "PV_" + str(i) config.add_section(index) config.set(index, "NAME", pv.pvname.get()) config.set(index, "TARGET", pv.target.get()) config.set(index, "LINUX_SOUND", pv.LinuxSound) config.set(index, "WINDOWS_SOUND", pv.WindowsSound) config.set(index, "WINDOWS_SOUND_TYPE", pv.WindowsSoundType) i = i + 1 config.write(f)
def On_save_button(self): # Open the file via dialog save_file = tkFileDialog.asksaveasfile( mode='wb', title='Save Nozzle Design Parameters', **self.pkl_file_opt) # pickle the engine parameters to the file pickle.dump(self.params, save_file) # close the file save_file.close()
def save_com(event=None): file = tkFileDialog.asksaveasfile(mode='w', defaultextension='.txt', filetypes=(("Text Files", "*.txt"), ("All Files", "*.*"))) if file: file.write("\n") file.write("\tBudget Buddy Results " + "\n\n") file.write("\tMonth: " + (mon.get()) + "\n\n\n") file.write("\tMonthly Income: " + (inca.get().rjust(4)) + "\n\n") file.write("\t Rent/Mortgage: " + (a1.get().rjust(4)) + "\n") file.write("\t Utilities: " + (a2.get().rjust(4)) + "\n") file.write("\t Internet/TV: " + (a3.get().rjust(4)) + "\n") file.write("\t Car Insurance: " + (a4.get().rjust(4)) + "\n") file.write("\t Car Payment: " + (a5.get().rjust(4)) + "\n") file.write("\t Home Insurance: " + (a6.get().rjust(4)) + "\n") file.write("\t Health Insurance: " + (a7.get().rjust(4)) + "\n") file.write("\t Water/Sewer: " + (a8.get().rjust(4)) + "\n") file.write("\t Food/Groceries: " + (a9.get().rjust(4)) + "\n") file.write("\t Gas/Fuel: " + (a10.get().rjust(4)) + "\n") file.write("\t Phone: " + (a11.get().rjust(4)) + "\n") file.write("\t Personal Items: " + (a12.get().rjust(4)) + "\n") file.write("\t Entertainment: " + (a13.get().rjust(4)) + "\n") file.write("\t Other: " + (a14.get().rjust(4)) + "\n\n") file.write("\t Total Costs: " + (a15.get().rjust(4)) + "\n") file.write("\t Remainder: " + (a16.get().rjust(4)) + "\n\n") file.close()
def filesave_cb(): if (packedservovals != None): f = tkFileDialog.asksaveasfile(mode='w', defaultextension='srv') f.write(packedservovals) f.close() else: tkMessageBox.showerror(title='Error!', message='You can not save, when one, or more values inconsistent.')
def ss(): by_spec = fileinf_ent.get() data = file(by_spec, "r").readlines() infile = asksaveasfile( mode="w", defaultextension=".csv", title="Save List of Taxa Sorted Alphabetically By Species Name") outfilename.set(infile.name) infile.write("Species & Lower Ranks,Species,Family,Genus\n") for line in data: line = line.strip("\n") correct_name = line.split("\t") if len(correct_name) == 2: correct_name = correct_name[1] correct_name = correct_name.split() if len(correct_name) == 2: colzero = "" colone = " ".join(correct_name) colthree = correct_name[0] coltwo = famgen_dict.get(correct_name[0], "Unavailable") infile.write(colzero + "," + colone + "," + coltwo + "," + colthree + "\n") infile.flush() infile.close()
def __init__(self, parent, project): self.project = project #tkSimpleDialog.Dialog.__init__(self, parent, 'Save As') ftypes = [('Log files', '*.log')] filename = tkFileDialog.asksaveasfile(title='Save As', filetypes = ftypes) if filename and len(filename.name) != 0: self.project.saveAsProject(filename.name)
def save_to_file(self): file = tkFileDialog.asksaveasfile(mode='w', **self.save_opt) try: assert self.output_data except AttributeError, AssertionError: tkMessageBox.showwarning('Error', 'No result to save.') return
def saveas_command(): contents = text.get('1.0', 'end-1c') file = tkFileDialog.asksaveasfile(mode='w', filetypes=[('all files', '.*'), ('text files', '.txt')]) file.write(contents) file.close()
def save_as_files(): global files data = textbox.get('0.0', 'end-1c') files = tkFileDialog.asksaveasfile() files.write(data) files.flush() return None
def exporting(self): """Export the IGV plot.""" filename = tkFileDialog.asksaveasfile(mode='w', defaultextension='.png') out_file = filename if (out_file): temp_image = Image.open('{}local_scripts/recent_runs/trio_igv.png'.format(self.var_gui_abs_path)) temp_image.save(filename)
def stat_out(): statfile = asksaveasfile(mode="w", defaultextension=".csv", title="Save Stats for this Flora") statfile.write(accnum_ent.get() + "\n") statfile.write("\n") statfile.write(",Family,Genus,Species, Species & Lower Ranks\n") statfile.write("Reported Values in FloraS Database:," + str(entryfour.get()) + "," + str(entryfive.get()) + "," + str(entrysix.get()) + "," + str(entryseven.get()) + "\n") statfile.write("Curated List:," + str(entryone.get()) + "," + str(entrytwo.get()) + "," + str(entrythree.get()) + "," + str(entryeight.get()) + "\n") statfile.write("\n") statfile.write("Unnamed Hybrids removed: " + hy_count.get() + "\n") statfile.write("Unnamed species (sp.) removed: " + unnamed_sp_count.get() + "\n") statfile.flush() statfile.close() varone.set(0) vartwo.set(0) varthree.set(0) varinfrasp.set(0) varfour.set(0) varfive.set(0) varsix.set(0) varseven.set(0) vareight.set("na") varnine.set("na") varten.set("na") vareleven.set("na") default_acc_num.set(0) filename.set('None') outfilename.set('None') rm_hybrids_num.set(0) rm_sp_num.set(0)
def savetofile(): savefile=tkFileDialog.asksaveasfile() stringToSave="" for i in kids: stringToSave=stringToSave+i+"," stringToSave=stringToSave[:-1] savefile.write(stringToSave)
def scanFolder(): folder = askdirectory() if (folder != ""): try: output = subprocess.Popen(["./antiv", "scanfolder", folder], stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0] r = re.compile("\033\[[0-9;]+m") output = r.sub("", output) another_window = Tk() s = Tkinter.Scrollbar(another_window) T = Tkinter.Text(another_window) T.focus_set() s.pack(side=Tkinter.RIGHT, fill=Tkinter.Y) T.pack(side=Tkinter.LEFT, fill=Tkinter.Y) s.config(command=T.yview) T.config(yscrollcommand=s.set) T.insert('1.0', output) #tkMessageBox.showinfo("Scan Report", output) response = tkMessageBox.askyesno("Save", "Do you want to save report ?") if response == True: f_report = asksaveasfile(mode='w', defaultextension=".txt") if f_report is None: # asksaveasfile return `None` if dialog closed with "cancel". pass else: f_report.write(output) f_report.close() except: pass
def __save(self): instructions = _EtcInstructions if self.script_style == 'data': instructions = _DataInstructions if self.script_type: ext = '.sh' self.script_msg += '\necho '.join(instructions.split('\n')) else: ext = '.bat' self.script_msg += '\r\nECHO '.join(instructions.split('\n')) self.script_msg += '\r\nPAUSE' if self.script_style == 'data': fname = 'getNCDCData-%s%s' % ('-'.join(self.update.stns),ext) else: fname = 'getNCDC-ISHFile%s' % ext fh = tkFileDialog.asksaveasfile(initialfile=fname, defaultextension=ext, initialdir='tmp') if fh: fh.write(self.script_msg) os.chmod(fh.name, stat.S_IRWXU|stat.S_IRWXG) fh.close() if self.script_style == 'data': del self.update.win.cdscripts self.update.win.continue_btn.configure(state=ACTIVE) self.close()
def save_file(): """saves the file in a particular format to be parsed if opened""" file = asksaveasfile(mode='w', defaultextension=".txt") for person in individuals: file.write( str(person.name + "," + person.firstname + "," + person.phone + "," + person.adress + "," + person.city + ":"))
def save_command(): file = tkFileDialog.asksaveasfile(mode='w') if file != None: # slice off the last character from get, as an extra return is added data = txt.get('1.0', END + '-1c') file.write(data) file.close()
def writeAlignIt(self): file = tkFileDialog.asksaveasfile(parent=self.parent, filetypes=[('Pharmacophore', '*.phar')], title='Save pharmacophore') if file == None: self.log("ERROR: cannot save file.") sys.exit(1) file.write('Generated_by_AlignIt_Pymol_Plugin\n') for p in self.phar: if (p[5] != "0"): file.write(p[0] + '\t' + str(p[1]) + '\t' + str(p[2]) + '\t' + str(p[3]) + '\t' + str(p[4]) + '\t' + str(p[5]) + '\t' + str(p[6]) + '\t' + str(p[7]) + '\t' + str(p[8]) + '\n') else: file.write(p[0] + '\t' + str(p[1]) + '\t' + str(p[2]) + '\t' + str(p[3]) + '\t' + str(p[4]) + '\t' + str(p[5]) + '\t' + "0.000" + '\t' + "0.000" + '\t' + "0.000" + '\n') file.write('$$$$\n') file.close() self.log("Done writing pharmacophore.")
def Main(): if Browse: rootdir=dirnameroot maincsv=tkFileDialog.asksaveasfile(title='export results to file', mode='w', defaultextension=".csv") for folder in os.listdir(rootdir): if os.path.isdir(os.path.join(rootdir, folder)) : Calc_for_well(os.path.join(rootdir, folder),maincsv) plt.close('all') else: rootdir=dirnamelow rootdir2=dirnamehigh highenergy=Dicom(rootdir,Check,Mask_saturated) lowenergy=Dicom(rootdir2,Check,Mask_saturated) (Density,Pe,Phi,nnslices,AvgLowCT,AvgHighCT,Zeff)=Calculate_Parameters(lowenergy,highenergy,Mask_saturated) Tbox.insert(END, "Density mean value: "+str(np.mean(Density))+"\n") Tbox.insert(END, "Photoelectric factor mean value: "+str(np.mean(Pe))+"\n") Tbox.insert(END, "Atomic number mean value: "+str(np.mean(Zeff))+"\n") Tbox.insert(END, "Porosity mean value: "+str(np.mean(Phi))+"\n") path=os.path.abspath(os.path.join(rootdir, os.pardir)) mslices=np.arange(0,nnslices,1) if Show_Plot: Plot2(lowenergy,Density,Pe,Phi,mslices) sys.stdout.write("\n Script finished \n Skipped+Skippedfolders+Folders")
def fetch_output_file(): global output_file_var file_path = asksaveasfile() print(file_path.name) file_path.close() output_file_var.set(file_path.name) os.system("rm " + file_path.name)
def generateFile(self): filteredString = self.parseFilterString() if filteredString == "": txtWindow = popupWindow(self.master, "No filter string is entered \n kindly enter a filter string") self.master.wait_window(txtWindow.top) print "No filter is entered" return file = tkFileDialog.asksaveasfile(filetypes=(("text files", "*.txt"), ("All files", "*.*"))) #TODO: here parse the string according to the filter output the file #write data in the file v = open(file.name,'w') count = len(self.data) for i in range(0, count-2): for j in range(1, len(filteredString)): #TODO: chcek this out!... if re.match(self.data[i].rawLineString, filteredString[j]) != None: tempString = self.data[i].rawLineString tempFilter = filteredString[j] tempString = tempString.upper() tempFilter = tempFilter.upper() if tempString.find(tempFilter) != -1: print "Raw Data:"+ self.data[i].rawLineString v.writelines(self.data[i].rawLineString) break v.close()
def save_callback(): f = tkFileDialog.asksaveasfile(mode='w', defaultextension=".txt") if f is None: return for single_point in point_set: f.write(str(single_point.x) + " " + str(single_point.y) + "\n") f.close()
def file_save(self): f = tkFileDialog.asksaveasfile(mode='w', defaultextension=".txt") if f is None: # asksaveasfile return `None` if dialog closed with "cancel". return text2save = str(text.get(1.0, END)) # starts from `1.0`, not `0.0` f.write(text2save) f.close()
def file_save2(self): Out=str(rospy.Time.now())+", "+str(self.x)+" "+str(self.y)+" "+str(self.z)+" "+str(self.Rz)+" "+str(self.Ry)+" "+str(self.Rx)+"\n" f2 = tkFileDialog.asksaveasfile(mode='a', defaultextension="",initialdir="/home/philip/FastResults/Calibration/") if f2 is None: # asksaveasfile return `None` if dialog closed with "cancel". return f2.write(Out) f2.close() # `()` was missing.
def save_as(): global saved_filename handle = tkFileDialog.asksaveasfile(mode='w') if handle: saved_filename = handle.name model.save(saved_filename) update_ui_hints(None)
def export(): """Run the real estate program""" types = 'CSV {.csv}', 'Text {.txt}', 'All *' filehandle = tkFileDialog.asksaveasfile(filetypes=types) if filehandle: realestate.realestate(command.get(), search.get(), filehandle) filehandle.close()
def set_default(self): today = datetime.date.today().strftime('%Y%m%d') config_name = 'defaultinstruments_%s' % (today) f = tkFileDialog.asksaveasfile(mode = 'w', initialdir = 'defaultinstruments', initialfile = config_name, defaultextension = '.dat') for str_elem in self.initbox.get(0,tk.END): f.write('%s\n' % str_elem) return None
def saveas(): f = tkFileDialog.asksaveasfile(mode='w', defaultextension=".txt", title="Save the scan as...") if f is None: # asksaveasfile return `None` if dialog closed with "cancel". return textoutput = tekst_widget.get(0.0, END) f.write((unicode(textoutput))) f.write("\n")
def _save_as(self): if self.nb.tab(self.nb.select(), "text") == "control.F" : name = tkFileDialog.asksaveasfile(mode='w',filetypes=[('control files','.F'),('all files','.*')]) text2save=str(self.txt_control.get(0.0,tk.END)) name.write(text2save) name.close elif self.nb.tab(self.nb.select(), "text") == "POSFF": name = tkFileDialog.asksaveasfile(mode='w',filetypes=[('POSFF','POSFF* CONTFF*'),('all files','.*')]) text2save=str(self.txt_posff.get(0.0,tk.END)) name.write(text2save) name.close elif self.nb.tab(self.nb.select(), "text") == "log": name = tkFileDialog.asksaveasfile(mode='w',filetypes=[('all files','.*')]) text2save=str(self.txt_stdout.get(0.0,tk.END)) name.write(text2save) name.close
def save_cal(self, event='<Control-Alt-s>'): f = tkFileDialog.asksaveasfile(mode='w', defaultextension='.cal') if f is None: self.status.config(text='Calibration save failed') return self.cal.write(f) self.status.config(text='Calibration saved successfully')
def save_file(self, path): """ retrieve informations from the GUI to generate the markdown document and save it """ title = self.title_entry.get() date = self.date_entry.get() categories = self.category_entry.get() tags = self.tags_entry.get() summary = self.summary_entry.get() body = self.body_entry.get(1.0, tk.END).strip() author = getpass.getuser() slug = self.clean_title(title) f = tkFileDialog.asksaveasfile(mode='w', defaultextension=".md", initialdir=path) if f is None: return text_to_save = u"""Title: {0} Date: {1} Category: {2} Tags: {3} Author: {4} Slug: {5} Summary: {6} {7} """.format(title, date, categories, tags, author, slug, summary, body) f.write(text_to_save) name = f.name f.close() return name
def output_filter(self): """ Save filter results into .txt file """ if not self.chapter_status: return # Filter information filter_info = self.show_filter() # Apply filter results = self.qd.filter(include=self.include_dict, exclude=self.exclude_dict, score=self.score_lst) # Display information into message box msg = '%d cases matched\n\n' % len(results) self.msg.config(text=msg + filter_info) self.mycanvas2.canvas.xview_moveto(0.0) self.mycanvas2.canvas.yview_moveto(0.0) # Output format filter_results = '\n'.join( map(lambda v: '#' + v, sorted(results))) # add hash in front of each problem filter_outcome = msg + filter_info + '\n' + filter_results # Save result to file f = tkFileDialog.asksaveasfile(mode='w', defaultextension='.txt') if f is None: return f.write(filter_outcome) f.close()
def save_file(): if digit_filename is None: digit_file = tkFileDialog.asksaveasfile(mode='w', **file_options) else: digit_file = open(digit_filename, 'w') if digit_file: save_digits(digit_file)
def save(): f = tkFileDialog.asksaveasfile(mode='w', defaultextension=".txt") if f is None: # asksaveasfile return `None` if dialog closed with "cancel". return f.write(varString) f.close() # `()` was missing. print "Sequence Saved!"
def at_export(data=np.ones((0, 0)), data_ID=False, fmt='%.4e', mode='a'): r""" A simple function to export a Numpy ndarray as a CSV text file. You can use this function to export "any Numpy array data" for further manipulations. :param data: Numpy ndarray :param data_ID: a string to represent the data being exported :param fmt: str or sequence of strs. For more information, see numpy.savetxt. :param mode: file opening mode, e.g., 'w', 'a', etc :rtype: A CSV text file """ master = ti.Tk() master.withdraw() # hiding tkinter window file_path = tkdlg.asksaveasfile(mode, title="Save file", filetypes=[("txt file", ".csv"), ("All files", ".*")]) master.quit() if (data_ID): file_path.write(data_ID + '\n' + '\n') np.savetxt(file_path, data, delimiter=',', fmt=fmt) file_path.write('\n') return
def save_as_command(): """get a filename and save your text to it""" # default extension is optional, will add .txt if missing fout = tkFileDialog.asksaveasfile(mode='w', defaultextension=".txt") text2save = str(textbox.get(0.0, 'end')) fout.write(text2save) fout.close()
def save_file(): """Returns an opened file in write mode.""" app.withdraw() #hides the browse window file_path = tkFileDialog.asksaveasfile(mode='w', **app.file_opt_out) app.deiconify( ) #wraca do glownego okna, w stanie w jakim zostalo przed wczytaniem pliku return file_path
def variance(self, list_of_groups=None): list_of_groups = self.group_hash.keys() x_values = self.check_compatibility(list_of_groups) sorted_x = sorted(list(x_values)) y_tracker = [] file_chosen = asksaveasfile(mode='wb') #writer = csv.writer(file_chosen, delimiter = ' ') list_of_rows = [] for x in sorted_x: temp_list = [] num_ys = 0 for group in list_of_groups: for spectra in self.group_hash[group].spectralList: temp_list.append(spectra.y_to_x[x]) num_ys += 1 form = [trunc(float(x), 4), trunc(float(sum(temp_list) / num_ys), 4)] y_tracker.append(float(sum(temp_list) / num_ys)) list_of_rows.append(form) save_variance = saveFile(file_chosen, list_of_rows) save_variance.save_mestrenova() mp.plot_interp(x=sorted_x, y=y_tracker)
def exportToLatex(self): f = tkFileDialog.asksaveasfile(mode="w", defaultextension=".tex") if f is None: return self.trail.exportToLatex(f) f.close()
def csv(self): filename = tkFileDialog.asksaveasfile(**self.file_opt) writer = csv.writer(filename, delimiter = ',') writer.writerow( ('File path', 'File name', 'PowerHash')) for i in range(len(self.hash[1])): writer.writerow((self.hash[1][i][0], self.hash[1][i][1], self.hash[1][i][2])) filename.close()
def exportSDF(self): sel = self.tree.focus() if self.tree.parent(sel) != '': sel = self.tree.parent(sel) f = tkFileDialog.asksaveasfile(parent=self, filetypes=(('SDFile', '*.sdf'), ("All files", "*.*"))) sdf = sel.split(':')[2] suppl = Chem.SDMolSupplier(sdf) for i in self.tree.get_children(sel): try: mi = suppl.next() except: continue mb = Chem.MolToMolBlock(mi) f.write(mb) f.write('> <' + sel.split(':')[0] + '>\n' + self.tree.set(i, 'a').strip() + '\n\n') f.write('> <AD>\n' + self.tree.set(i, 'b').strip() + '\n\n') f.write('> <CI>\n' + self.tree.set(i, 'c').strip() + '\n\n') f.write('$$$$\n') f.close()
def _save_file(self): save_file = tkFileDialog.asksaveasfile() if save_file is None: return save_file.write(str(self._text_log.get('1.0', tk.END))) save_file.close()
def write_siemens_direction_file(bvecs, bvals, out_path): """ Write a .dvs file to be used by a Siemens scanner for a diffusion scanner INPUTS: bvecs: list of unit vectors of diffusion directions bvals: list of b-values corresponding to each of the above directions out_path: name and location of the .dvs file """ maxB = np.max(bvals) for i in range(len(bvals)): bvecs[i, :] = bvecs[i, :] * np.sqrt(float(bvals[i]) / float(maxB)) if out_path == "None": f1 = tkFileDialog.asksaveasfile(mode='w', defaultextension=".dvs") else: f1 = open(out_path, 'w+') f1.write( '[Directions=%d]\nCoordinateSystem = XYZ\nNormalisation = None\n' % len(bvals)) for i in range(len(bvals)): f1.write('vector[ %d] = ( %f, %f, %f )\n' % (i, bvecs[i, 0], bvecs[i, 1], bvecs[i, 2])) f1.close()
def saveAs(): f = tkFileDialog.asksaveasfile(mode='w', defaultextension=".txt") if f is None: return textToSave = str(text.get(1.0, END)) f.write(textToSave) f.close()
def write_phillips_direction_file(bvecs, bvals, out_path): """ Write a .txt file to be used by a Siemens scanner for a diffusion scanner INPUTS: bvecs: list of unit vectors of diffusion directions bvals: list of b-values corresponding to each of the above directions out_path: name and location of the .txt file """ for i in range(len(bvals)): if (bvals[i] == 0 and i == 0): bvecs[i, :] = np.random.rand(1, 3) bvecs[i, :] = bvecs[i, :] / np.linalg.norm(bvecs[i, :]) elif (bvals[i] == 0 and i != 0): bvals[i] = 0.01 bvecs[i, :] = np.random.rand(1, 3) bvecs[i, :] = bvecs[i, :] / np.linalg.norm(bvecs[i, :]) if out_path == "None": f1 = tkFileDialog.asksaveasfile(mode='w', defaultextension=".txt") else: f1 = open(out_path, 'w+') for i in range(len(bvals)): f1.write('%f %f %f %f\n' % (bvecs[i, 0], bvecs[i, 1], bvecs[i, 2], bvals[i])) f1.close()
def file_save(self): '''This function use to save graph''' save = tkFileDialog.asksaveasfile(mode = 'w', defaultextension = ".png") if save is None: # asksaveasfile return `None` if dialog closed with "cancel". return self.fig.savefig(save.name) save.close()
def save_command(self): file_handler = tkFileDialog.asksaveasfile(mode='w') if file_handler is not None: # slice off the last character from get, as an extra return is added data = self.textPad.get('1.0', tk.END + '-1c') file_handler.write(data) file_handler.close()
def doSaveAs(self): # Returns the saved file file = tkFileDialog.asksaveasfile(mode='w') self.savefile = file textoutput = self.text.get(0.0, END) # Gets all the text in the field file.write(textoutput.rstrip()) # With blank perameters, this cuts off all whitespace after a line. file.write("\n") # Then we add a newline character.
def saveOutput(self): fname = tkFileDialog.asksaveasfile(mode='w', defaultextension=".bmp") if fname: try: self.Img.rgb_img.save(fname) except IOError as e: showerror("Cannot save file", "Failed to save file\n'%s'" % fname)
def doSaveAs(self): # Returns the saved file file = tkFileDialog.asksaveasfile(mode='w') textoutput = self.text.get(0.0, END) # Gets all the text in the field file.write(textoutput.rstrip( )) # With blank perameters, this cuts off all whitespace after a line. file.write("\n") # Then we add a newline character.
def save_cal(self, event = '<Control-Alt-s>'): f = tkFileDialog.asksaveasfile(mode = 'w', defaultextension = '.cal') if f is None: self.status.config(text = 'Calibration save failed') return self.cal.write(f) self.status.config(text = 'Calibration saved successfully')
def saveFile(self): n = self.stepNumber s = self.sentence v = self.variable r = self.reference f = tkFileDialog.asksaveasfile(mode='w', defaultextension=".prf") if f is None: # asksaveasfile return `None` if dialog closed with "cancel". return f.write("proof" + "\n") for i in range(0, len(n)): if lines[i].isNew == "true": f.write("done\n" + "\n" + "proof\n") step2save = str( n[i].cget("text")) # str(n[i].cget("text")).splitlines() text2save = str(s[i].get( 1.0, "end")) # str(s[i].get(1.0, "end")).splitlines() text2save = text2save[:len(text2save) - 1] rule2save = v[i].get() refs2save = str(r[i].get(1.0, "end")) f.write(step2save + "\t" + text2save + "\t" + rule2save + "\t" + refs2save) lines[i].step = step2save lines[i].sentence = text2save lines[i].rule = rule2save lines[i].reference = refs2save f.write("done" + "\n") f.close()