本文整理汇总了Python中tkinter.filedialog.asksaveasfile函数的典型用法代码示例。如果您正苦于以下问题:Python asksaveasfile函数的具体用法?Python asksaveasfile怎么用?Python asksaveasfile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了asksaveasfile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: Run
def Run():
m = input('Please select a month, format mm: ')
y = input('Please select a year, format yyyy: ')
comment_option = input('Would you like MedTech Comment emails to be included? Y/N: ')
yes_var = ['Yes', 'YES', 'y', 'Y']
no_var = ['No', 'NO', 'n', 'N']
facility_file = open('facilityList.txt', 'r')
incident_file = askopenfile(mode='r', initialdir="C:/Documents and Settings/medinc.LGBS/Desktop", title='Please select an incident file!')
d = get_facilities(facility_file)
incident_list = populate_incident_list(incident_file)
mincident_list = list(filter(lambda x: find_date_submitted(x)[0:2] == m, incident_list))
myincident_list = list(filter(lambda x: find_date_submitted(x)[6:10] == y, mincident_list))
if comment_option in yes_var:
final_list = [('\t' * 15) + d[find_facility_name(incident)] + '\n' + incident for incident in myincident_list]
if comment_option in no_var:
final_list = [('\t' * 15) + d[find_facility_name(incident)] + '\n' + incident for incident in myincident_list if boolComments(incident) == False]
final_list.sort(key=lambda i: (i[15:18], find_DS_forSort(i)))
date_of_incident_before_m = [alert for alert in final_list if find_date_of_incident(alert)[0:2] != m]
new_final_list = list(filter(lambda alert: find_date_of_incident(alert)[0:2] == m, final_list))
final_file = asksaveasfile(mode='w', defaultextension=".html", filetypes=(("HTML file", "*.html"),("All Files", "*.*")),
initialdir="C:/Documents and Settings/medinc.LGBS/Desktop",
title='Please choose a name for the file with this month\'s DOIs!')
prior_file = asksaveasfile(mode='w', defaultextension=".html", filetypes=(("HTML file", "*.html"),("All Files", "*.*")),
initialdir="C:/Documents and Settings/medinc.LGBS/Desktop",
title='Please choose a name for the file with prior month\'s DOIs!')
html_styling = ('<html>' + '<head>' + '<style>' + 'hr { page-break-before: always;}' + '''pre {
white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap;
word-wrap: break-word;}''' + '</style>' + '</head>' + '<body>')
final_file.write(html_styling)
for alert in new_final_list:
final_file.write('<pre>' + '<font size= "4" face= "Ariel">' +
cgi.escape(alert) + '</font>' + '</pre>' + '<hr>')
final_file.write('</body>' + '</html>')
final_file.close()
prior_file.write(html_styling)
for alert in date_of_incident_before_m:
prior_file.write('<pre>' + '<font size= "4" face= "Ariel">' +
cgi.escape(alert) + '</font>' + '</pre>' + '<hr>')
prior_file.write('</body>' + '</html>')
prior_file.close()
print('Sorting complete! Please open html files to see results.')
开发者ID:hillmandj,项目名称:sort_bot,代码行数:58,代码来源:MedTech_v5.py
示例2: write_dep
def write_dep(self, Z, fname = None, grid_fname = None):
if not fname:
fname = filedialog.asksaveasfile()
else:
fname = fname
if not grid_fname:
if np.ndim(Z) == 1:
m = np.shape(Z)[0]
n = 1
else:
m = np.shape(Z)[0]
n = np.shape(Z)[1]
else:
grid_fname = grid_fname
grid = grd.grd()
grid.read_grd(fname = grid_fname)
m = grid.m
n = grid.n
Z = np.array([np.append(i,-999.) for i in Z])
Z = np.insert(Z, -1, np.ones(np.shape(Z[0]))*-999.)
Z = Z.reshape((m+1, n+1))
np.savetxt(fname, Z, delimiter = '\t', fmt = '%.3f')
print('saved depth file: %s' %os.path.basename(fname))
self.read_dep(fname)
开发者ID:spmls,项目名称:pydelft,代码行数:28,代码来源:dep.py
示例3: note_save_as
def note_save_as(self, event = None):
f = filedialog.asksaveasfile(mode='w', defaultextension=".txt") # opens file save dialog
if f is None: # asksaveasfile return `None` if dialog closed with "cancel".
return
text_to_save = str(self.textbox.get(1.0, tk.END))
f.write(text_to_save)
f.close()
开发者ID:Loc-Tran,项目名称:PySticky,代码行数:7,代码来源:main.py
示例4: save_as
def save_as():
file = asksaveasfile(defaultextension='.txt')
data = text_area.get(0.0, END)
try:
file.write(data.rstrip())
except:
tkinter.messagebox.showinfo("Cancel", "File Not Saved!")
开发者ID:v4iv,项目名称:Peach,代码行数:7,代码来源:peach.py
示例5: save_command
def save_command():
file = filedialog.asksaveasfile(mode='w')
if file != None:
# slice off the last character from get, as an extra return is added
data = textPad.get('1.0', END+'-1c')
file.write(data)
file.close()
开发者ID:sindhya,项目名称:TextEditor,代码行数:7,代码来源:Nova.py
示例6: save_input
def save_input():
file2save = filedialog.asksaveasfile(mode = 'w', defaultextension = ".txt")
if file2save is None:
return
inputtext = str(textfield.get("1.0", END))
file2save.write(inputtext)
file2save.close()
开发者ID:rlenart360,项目名称:TextEditor,代码行数:7,代码来源:text_editor.py
示例7: saveAs
def saveAs():
f = asksaveasfile(mode='w',defaultextension='.txt')
t = text.get(0.0,END)
try:
f.write(t.rstrip())
except:
showerror(title="Error",message="File save fail...")
开发者ID:damanjitsingh,项目名称:pythonPrograms,代码行数:7,代码来源:readNWriteTextFiles.py
示例8: saveAs
def saveAs():
f = filedialog.asksaveasfile(mode='w', defaultextension='.txt')
t = text.get(0.0, END)
try:
f.write(t.rstrip())
except:
showError(title="Ooops!", message="Unable to save file.")
开发者ID:SpyR1014,项目名称:Little_Python_Projects,代码行数:7,代码来源:TextEditor.py
示例9: text_save
def text_save():
f = filedialog.asksaveasfile(mode='w', defaultextension=".txt")
if f is None: # asksaveasfile return `None` if dialog closed with "cancel".
return
text2save = """<html><body> """ + body + """ </body></html>"""
f.write(text2save)
f.close()
开发者ID:Nic-Coons,项目名称:python-projects,代码行数:7,代码来源:make-htmlGUI.py
示例10: predict_test
def predict_test(self,toFile=False):
#Check that the testSet actually exists!
if len(self.testSet)>0:
#check that the test set contains the same number of levels as the train set
if sorted(self.targetLevels) == sorted(np.unique(self.encodedTargetTest)):
#testResults contain predictions of the test set predictors
testResults=self.predict_class(self.testPredictors)
#Accuracy is the number of predictions that match the actual values divided by the number of datapoints in the test set
accuracy=sum(list(map(lambda x: x[0]==x[1],zip(testResults,self.encodedTargetTest))))/len(testResults)
print('\nTest Accuracy','%s'% float('%.4g'%accuracy))
if toFile:
#simple GUI is convenient to use
from tkinter.filedialog import asksaveasfile
writelocation=asksaveasfile(mode='w+',defaultextension='.txt')
writelocation.write('Predicted | Actual \n')
#zip predicted an actual into tuples
pairedActualPredicted=zip(*[list(testResults),list(self.encodedTargetTest)])
for row in pairedActualPredicted:
#write each tuple to the file
writelocation.write('\n'+str(row))
if row[0]!=row[1]:
#Note any incorrect predictions
writelocation.write(' * incorrect prediction')
writelocation.close()
return accuracy
开发者ID:DavidLSmyth,项目名称:MLRegression,代码行数:25,代码来源:Assignment3.py
示例11: save
def save(self):
from tkinter import Tk
from tkinter.filedialog import asksaveasfile
Tk().withdraw()
simFile = None
try:
simFile = asksaveasfile(mode="wb", initialfile='untitled', defaultextension='sim',
filetypes=[("Newton's Laboratory Simulation File", ".sim")])
finally:
if simFile is None:
return
data = (self.bodies, self.constraints)
for group in data:
for obj in group:
obj.simulation = None
pickle.dump(data, simFile, pickle.HIGHEST_PROTOCOL)
simFile.close()
for d in data:
for x in d:
print(x.__dict__)
for group in data:
for obj in group:
obj.simulation = self
self.planet = self.bodies[0]
开发者ID:Tochicool,项目名称:Newt,代码行数:32,代码来源:sim.py
示例12: mergeFiles
def mergeFiles():
pdfFile = []
reader = []
writer = PyPDF2.PdfFileWriter()
mylistboxProgress.delete(0, tk.END)
if mylistbox.size() > 1:
for i in range(0, len(fileName)):
#print(reader[i])
pdfFile.append(open(fileName[i], 'rb'))
reader.append(PyPDF2.PdfFileReader(pdfFile[i]))
mylistboxProgress.insert(i, extractName(fileName[i]+" - Progress: " + str(((i+1)/len(fileName))*100)+" %"))
for pageNum in range(reader[i].numPages):
page = reader[i].getPage(pageNum)
writer.addPage(page)
#pdfFile[i].close()
outputName = filedialog.asksaveasfile(title="Save As...", mode='a', defaultextension=".pdf", filetypes =[("Portable Document Format","*.pdf")])
if outputName:
outputFile = open(outputName.name, 'wb')
writer.write(outputFile)
outputFile.close()
mylistboxProgress.insert(tk.END, "File saved as: "+outputName.name)
else:
mylistboxProgress.insert(tk.END, "File not saved")
for i in range(0, len(pdfFile)):
pdfFile[i].close()
return
开发者ID:jcuartas,项目名称:Juan-s-PDF-Merger,代码行数:28,代码来源:JuansPDFMerger.py
示例13: save_file
def save_file():
file = filedialog.asksaveasfile(mode="w")
if file != None:
# chop the last character from get, as an added extra return
data = self.textPad.get("1.0", END + "-1c")
file.write(data)
file.close()
开发者ID:vaibhawvipul,项目名称:TextEditor-Python,代码行数:7,代码来源:TextEditor_VaibhawLabs.py
示例14: saveFile
def saveFile(content) :
'''
Use a Tkinter file dialog to allow the user to save content to a file.
This is used for the results window in the UI.
'''
file = filedialog.asksaveasfile(mode = 'w', defaultextension = '.txt', initialfile = "results")
if file != None : print(content, file = file)
开发者ID:charlesbos,项目名称:s-compare,代码行数:7,代码来源:main.py
示例15: __askSaveFilePath
def __askSaveFilePath(self, extension):
file_path = filedialog.asksaveasfile(mode="w", defaultextension=extension)
#check if user cancelled saveFileDialog
if file_path is None:
return
#self.image_editor.image.write(file_path, format=extension)
self.image_editor.image.save(str(file_path.name))
开发者ID:nebulak,项目名称:ImageEditor,代码行数:7,代码来源:gui.py
示例16: save_sequence
def save_sequence():
"""
Saves the assembled sequence to a designated location.
Args:
NONE
Returns:
NONE
Raises:
KeyError: Raises an exception.
"""
global filename
global issequencesaved
if filename == '':
messagebox.showerror("Error Message", "No import file")
elif issequencesaved == False:
f = filedialog.asksaveasfile(mode='w', defaultextension=".txt")
if f is None:
return
f.write(assembled_reads)
f.close()
issequencesaved = True
else:
messagebox.showerror("Error Message", "No assembled sequence")
开发者ID:jian5388,项目名称:DNA-Sequence-Assembly,代码行数:27,代码来源:DNA_sequence_assembler.py
示例17: execute_pip_commands
def execute_pip_commands(self):
"""
Execute the command for generating requirements file
"""
requirements_text = ''
for item in self.multi_items_list.scroll_tree.selection():
item_dict = self.multi_items_list.scroll_tree.item(item)
requirements_text += '{}=={}\n'.format(
item_dict['values'][0],
item_dict['values'][1])
from tkinter.filedialog import asksaveasfile
from os.path import expanduser
file_pt = asksaveasfile(
mode='w',
defaultextension='.txt',
initialdir=expanduser('~'))
if file_pt is None:
return
file_pt.write(requirements_text)
file_pt.close()
开发者ID:upendra-k14,项目名称:pip_gui,代码行数:25,代码来源:manage_installed_modules_page.py
示例18: test
def test():
# MessageBox.showinfo("Hola!","Hola mundo")
# MessageBox.showwarning("Alerta","Sección sólo para administradores.")
# MessageBox.showerror("Error!","Ha ocurrido un error inesperado.")
# resultado = MessageBox.askquestion("Salir","¿Está seguro que desea salir sin guardar?")
# if resultado == "yes": # "no"
# root.destroy()
# resultado = MessageBox.askokcancel("Salir","¿Sobreescribir el fichero actual?")
# resultado = MessageBox.askyesno("Salir","¿Está seguro que desea salir sin guardar?")
#if resultado:
# root.destroy()
#resultado = MessageBox.askretrycancel("Reintentar","No se puede conectar")
#if resultado:
# root.destroy()
#color = ColorChooser.askcolor(title="Elige un color")
#print(color)
#ruta = FileDialog.askopenfilename(title="Abrir un fichero", initialdir="C:",
# filetypes=(("Fichero de texto","*.txt"),
# ("Fichero de texto avanzado","*.txt2"),
# ("Todos los ficheros","*.*")) )
#print(ruta)
# equivale a open('ruta','w')
fichero = FileDialog.asksaveasfile(title="Guardar un fichero", mode="w", defaultextension=".txt")
if fichero is not None:
fichero.write("Hola voy a escribir otra cosa!")
fichero.close()
开发者ID:cmcm21,项目名称:Python-3-al-completo-desde-cero,代码行数:26,代码来源:popups.py
示例19: kmlWriter
def kmlWriter(self):
self.namePosit = int(self.nameList.curselection()[0])
self.latPosit = int(self.latList.curselection()[0])
self.lonPosit = int(self.lonList.curselection()[0])
self.kmlFile = tfd.asksaveasfile(mode='w', defaultextension='*.kml', filetypes=[('kml File', '*.kml')])
self.kmlFile.write('<?xml version="1.0" encoding="UTF-8"?>\n<kml xmlns="http://www.opengis.net/kml/2.2">\n\t<Document>\n\t')
for row in self.sheet.get_squared_range(1,2,self.sheet.max_column,self.sheet.max_row):
self.kmlFile.write('<Placemark>\n\t')
self.kmlFile.write('<name>' + str(row[self.namePosit].value) + '</name>\n')
# Added CDATA tag to solve issue of special characters causing xml to crash.
self.kmlFile.write('\t<description> <![CDATA[ \n\t\t\t')
# initializes the count method used to loop through description
self.c = 1
for colDesc in row:
self.kmlFile.write(str(self.sheet.cell(row=1,column=self.c).value) +': ' + str(colDesc.value) + '\n\t\t\t')
self.c += 1
self.kmlFile.write(']]> \n\t\t </description>')
self.kmlFile.write('<Point>\n\t\t<coordinates>'+str(row[self.lonPosit].value) + ','+ str(row[self.latPosit].value) + ',0</coordinates>\n\t</Point>')
self.kmlFile.write('\n\t</Placemark>\n\t')
self.kmlFile.write('</Document></kml>')
self.kmlFile.close()
#Updates the label to indicate conversion is complete.
self.complete.set("Conversion Complete!")
开发者ID:flynnpc,项目名称:G-gizmo,代码行数:28,代码来源:kmlwriter3.py
示例20: Save_as
def Save_as(self):
f = fd.asksaveasfile(mode='w')
self.cfile = f.name
self.master.wm_title('XRead Text Editor - '+self.cfile)
f.write(self.text.get("1.0",END))
f.close()
self.file_is_saved=True
开发者ID:poikNplop,项目名称:XRead,代码行数:7,代码来源:XRead.py
注:本文中的tkinter.filedialog.asksaveasfile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论