当前位置: 首页>>代码示例>>Python>>正文


Python tkFileDialog.asksaveasfilename函数代码示例

本文整理汇总了Python中tkFileDialog.asksaveasfilename函数的典型用法代码示例。如果您正苦于以下问题:Python asksaveasfilename函数的具体用法?Python asksaveasfilename怎么用?Python asksaveasfilename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了asksaveasfilename函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: FindFile

 def FindFile(self):
     oldfile = self.value
     if self.action == "open":
         if self.filetypes:
             browsevalue=tkFileDialog.askopenfilename(initialfile=self.value,
                                                       filetypes=self.filetypes)
             self.browsevalue=str(browsevalue)
         else:
             browsevalue=tkFileDialog.askopenfilename(initialfile=self.value)
             self.browsevalue=str(browsevalue)
     else: # elif self.action == "save":
         if self.filetypes:
             browsevalue=tkFileDialog.asksaveasfilename(initialfile=self.value,
                                                             filetypes=self.filetypes)
             self.browsevalue=str(browsevalue)
         else:
             browsevalue=tkFileDialog.asksaveasfilename(initialfile=self.value)
             self.browsevalue=str(browsevalue)
     if len(self.browsevalue) == 0:
         self.browsevalue = oldfile
     if self.command:
         #self.command()
         # We pass browsevalue through, although the previous binding means that
         # the command must also be capable of receiving a Tkinter event.
         # See the interfaces/dalton.py __update_script method
         self.command( self.browsevalue )
         self.entry.setvalue(self.browsevalue)
         self.editor.calc.set_parameter(self.parameter,self.browsevalue)
     else:
         self.entry.setvalue(self.browsevalue)
         self.editor.calc.set_parameter(self.parameter,self.browsevalue)
开发者ID:alexei-matveev,项目名称:ccp1gui,代码行数:31,代码来源:tools.py

示例2: setupProfiles

    def setupProfiles(self):
        self.profileDialog=Toplevel(self.parent)
        self.fileBoxText=StringVar()
        msg=Message(self.profileDialog,text='This is your first time accessing profiles!\n\nProfiles allow you to save settings that work well for a particular journal or set of journals. \n\nTo begin, select the file in which to save your profile parameters:')
        msg.grid(row=0,column=0,sticky=W)
        fileBox=Entry(self.profileDialog,width=50,textvariable=self.fileBoxText)
        self.fileBoxText.set('./journal2ebook.txt')
        fileBox.grid(row=1,column=0,sticky=W)

        bBrowse=Button(self.profileDialog)
        bBrowse.configure(text='Browse')
        bBrowse.bind('<Button-1>',lambda event:self.fileBoxText.set(asksaveasfilename(parent=self.profileDialog,)))
        bBrowse.bind('<Return>',lambda event:self.fileBoxText.set(asksaveasfilename(parent=self.profileDialog,)))
        bBrowse.grid(row=1,column=1,sticky=W)

        bOK=Button(self.profileDialog)
        bOK.configure(text='OK')
        bOK.focus_force()
        bOK.bind('<Button-1>',self.profilesOK)
        bOK.bind('<Return>',self.profilesOK)
        bOK.grid(row=2,column=0,sticky=E)

        bCancel=Button(self.profileDialog)
        bCancel.configure(text='Cancel')
        bCancel.bind('<Button-1>',lambda event: self.profileDialog.destroy())
        bCancel.bind('<Return>',lambda event: self.profileDialog.destroy())
        bCancel.grid(row=2,column=1,sticky=W)
开发者ID:avichalp,项目名称:journal2ebook,代码行数:27,代码来源:journal2ebook.py

示例3: doThings

def doThings(ratio=gearRatio, overlap=gearOverlap, steps=computationSteps):
    inputGear = loadGearImage()
    offset = (ratio+1-overlap, 0)
    inputCoords, inputImageSize = getBlackPixels(inputGear, offset)
    outputImageSize = inputImageSize*ratio
    outputGear = np.zeros([outputImageSize, outputImageSize])
    theta = 2*np.pi/steps
    phi = 2*np.pi/(steps*ratio)
    # Rotation math
    for step in range(steps):
        coords = rotatePts(inputCoords, offset, theta*step)
        addPoints = []
        for coord in coords:
            if dist(*coord)<ratio:
                addPoints += [coord]
        # Rotate the points that contribute to the output gear's profile
        for extraRotation in range(ratio):
            rotateBy = phi*step + 2*np.pi*extraRotation/ratio
            addPointsRot = rotatePts(addPoints, (0,0), rotateBy)
            # Convert those points into pixels, draw on output gear
            outputGear = outputGearImage(outputGear, addPointsRot, outputImageSize, ratio)
        print('Progress: {}/{}'.format(step, steps)) # Debug
    # Clean up image
    outputGear = outputCleanup(outputGear)
    # Should also make little marks for centroids and distances
    # Animate?
    # Save image
    outFilename = tkFileDialog.asksaveasfilename(defaultextension='.png', initialfile='gear_output')
    writeOutputGear(outputGear, outFilename)
    # save the crossbar image too
    crossbar = drawCrossbar(inputImageSize*(ratio+1-overlap)/2)
    outFilename = tkFileDialog.asksaveasfilename(defaultextension='.png', initialfile='crossbar')
    writeOutputGear(crossbar, outFilename)
开发者ID:settinger,项目名称:pygear,代码行数:33,代码来源:main.py

示例4: convertLib

def convertLib():
	fileName=askopenfilename(title = "Input Library",filetypes=[('Eagle V6 Library', '.lbr'), ('all files', '.*')], defaultextension='.lbr') 
	modFileName=asksaveasfilename(title="Module Output Filename", filetypes=[('KiCad Module', '.mod'), ('all files', '.*')], defaultextension='.mod')
	symFileName=asksaveasfilename(title="Symbol Output Filename", filetypes=[('KiCad Symbol', '.lib'), ('all files', '.*')], defaultextension='.lib')
	
	logFile.write("*******************************************\n")
	logFile.write("Converting Lib: "+fileName+"\n")
	logFile.write("Module Output: "+modFileName+"\n")
	logFile.write("Symbol Output: "+symFileName+"\n")
	
	name=fileName.replace("/","\\")
	name=name.split("\\")[-1]
	name=name.split(".")[0]
	
	logFile.write("Lib name: "+name+"\n")
	
	try:
		node = getRootNode(fileName)
		node=node.find("drawing").find("library")	
		lib=Library(node,name)			
		modFile=open(modFileName,"a")
		symFile=open(symFileName,"a")			
		lib.writeLibrary(modFile,symFile)
	except Exception as e:
		showerror("Error",str(e)+"\nSee Log.txt for more info")		
		logFile.write("Conversion Failed\n\n")
		logFile.write(traceback.format_exc())
		logFile.write("*******************************************\n\n\n")
		return
	
	logFile.write("Conversion Successfull\n")
	logFile.write("*******************************************\n\n\n")		
	showinfo("Library Complete","The Modules and Symbols Have Finished Converting \n Check Console for Errors")
开发者ID:Jerome-PS,项目名称:Eagle2Kicad,代码行数:33,代码来源:Start.py

示例5: generate_java

def generate_java(canvas):
  jname=canvas.statusbar.getState(StatusBar.MODEL)[1][0]
  if not jname or jname=="Nonamed":
    jname=tkFileDialog.asksaveasfilename(filetypes=[("Java source code", "*.java")])
  else:
    if StringUtil.endswith(jname, ".py"):
      jname=jname[:len(jname)-3]+".java"
    jname=os.path.split(jname)[1]
    jname=tkFileDialog.asksaveasfilename(initialfile=jname, filetypes=[("Java source code", "*.java")], initialdir=canvas.codeGenDir)
  if jname:
    if StringUtil.endswith(jname, ".java"):
      mname=jname[:len(jname)-5]+".des"
    else:
      mname=jname+".java"

    desc=generate_description(canvas, 0)["desc"]
    eventhandler=EventHandler(mname, modeltext=desc)
    g=JavaGenerator(eventhandler)
    code=g.generate_code()

    # Save .java file
    jf=open(jname, "w")
    jf.write(code)
    jf.close()
    # Print on success
    print "Java code saved to: " + jname
开发者ID:pombreda,项目名称:comp304,代码行数:26,代码来源:SVMAToM3Plugin.py

示例6: _check_browse

	def _check_browse(self, index):
		if index == 0:
			return tkFileDialog.askopenfilename(defaultextension = FILES_JPT[0][1], filetypes = FILES_JPT)
		if index == 1:
			return tkFileDialog.asksaveasfilename(defaultextension = FILES_JPEG[0][1], filetypes = FILES_JPEG)
		if index == 2:
			return tkFileDialog.asksaveasfilename(defaultextension = FILES_PNG[0][1], filetypes = FILES_PNG)
		return FrameJpt._check_browse(index)
开发者ID:Ryex,项目名称:libapril,代码行数:8,代码来源:jpt-gui.py

示例7: export_plot_data

 def export_plot_data(self):
     if self.export_type == 'hist1d' or self.export_type == 'scatter':
         data_path = tkFileDialog.asksaveasfilename(defaultextension='.csv')
         np.savetxt(data_path,np.c_[self.xdata,self.ydata],delimiter=',')
     elif self.export_type == 'hist2d':
         data_path = tkFileDialog.asksaveasfilename(defaultextension='.csv')
         np.savetxt(data_path,np.c_[self.xdata,self.ydata,self.zdata],delimiter=',')
     else:
         self.status_string.set("Unable to export plot")
开发者ID:shadowk29,项目名称:cusumtools,代码行数:9,代码来源:readevents.py

示例8: exportMidiFile

 def exportMidiFile(self):
     #takes the current music on piano roll and exports it as a midi file
     self.createTimingTrack()
     timingTrack=self.noteTimingList
     if self.fileName!=None:
         fileName = tkFileDialog.asksaveasfilename(initialfile=
                                                   [self.fileName])
     else:fileName = tkFileDialog.asksaveasfilename(initialfile=['New.mid'])
     if fileName!='': #if there is a file name
         CreateMidi(fileName,timingTrack,self.ticksPerBeat)
开发者ID:cyshan,项目名称:piano-roll,代码行数:10,代码来源:pianoRoll.py

示例9: ask_savefile

def ask_savefile(initialfolder='.',title='Save As',types=None):
	"""Open a native file "save as" dialog that asks the user to choose a filename. The path is returned as a string.
	Specify types in the format ['.bmp|Windows Bitmap','.gif|Gif image'] and so on.
	"""
	import tkFileDialog
	if types!=None:
		aTypes = [(type.split('|')[1],type.split('|')[0]) for type in types]
		defaultExtension = aTypes[0][1]
		strFiles = tkFileDialog.asksaveasfilename(initialdir=initialfolder,title=title,defaultextension=defaultExtension,filetypes=aTypes)
	else:
		strFiles = tkFileDialog.asksaveasfilename(initialdir=initialfolder,title=title)
	return strFiles
开发者ID:downpoured,项目名称:pyxels,代码行数:12,代码来源:tkutil_dialog.py

示例10: _ask_path_to_file

 def _ask_path_to_file(self):
     """ Ask a path to the destination file. If a dir has been already specified,
     open the choice window showing this dir. """
     if not self.homeDir:
         fullPath = asksaveasfilename(**_DialogueLabels.save_output_file_choice)
     else:
         fullPath = asksaveasfilename(initialdir = self.homeDir, **_DialogueLabels.save_output_file_choice)
     if fullPath:
         dir, filename = os.path.split(fullPath)
         if dir:
             self.homeDir = dir
     return fullPath
开发者ID:sleepofnodreaming,项目名称:ruscorporaXML,代码行数:12,代码来源:tabgui.py

示例11: saveDonorsFile

 def saveDonorsFile(self):
     if (self.filename):
         self.filename = tkFileDialog.asksaveasfilename(
             defaultextension="xmas", parent=self, initialfile=self.filename)
     else:
         self.filename = tkFileDialog.asksaveasfilename(
             defaultextension="xmas", parent=self, initialdir=".")
     if (self.filename):
         print self.donors.str()
         self.outputFile = open(self.filename, 'w')
         self.outputFile.write(self.donors.str())
         self.outputFile.close() 
开发者ID:lbwelch,项目名称:ChristmasSecretSanta,代码行数:12,代码来源:main.py

示例12: getFiletoSave

def getFiletoSave(initialDir="",title=""):
    root = tk.Tk()
    if(title == ""):
        title = "Please select a file name to be saved"
        
    root.withdraw()
    if(initialDir != ""):
        file_path = tkFileDialog.asksaveasfilename(initialdir=initialDir,title=title)
    else:
        file_path = tkFileDialog.asksaveasfilename()
    root.destroy()

    return file_path
开发者ID:SamuelLBau,项目名称:HE_GUI,代码行数:13,代码来源:simpleDialogs.py

示例13: saveImg

 def saveImg(self):
     if self.operation.get() == 1 and self.encryptDone:
         savePath = tkFileDialog.asksaveasfilename(parent = self.frame, initialdir = '/home/st/Pictures', title = 'Save Encryted Data Image', filetypes = [('BMP', '.bmp'), ('PNG', '.png')])
         if savePath != "":
             self.dataImage.save(savePath)
             tkMessageBox.showinfo('Infos', 'Encrypted Image Save Success!\npath: %s' % savePath)
     elif self.operation.get() == 2 and self.decryptData is not None:
         savePath = tkFileDialog.asksaveasfilename(parent = self.frame, initialdir = '/home/st/', title = 'Save Decryted Data File')
         if savePath != "":
             saveFile = open(savePath, 'w')
             saveFile.writelines(self.decryptData)
             saveFile.close()
             tkMessageBox.showinfo('Infos', 'Dncrypted Data File Save Success!\npath: %s' % savePath)
开发者ID:hnuxbl,项目名称:InfoHiding,代码行数:13,代码来源:FileHideFrame.py

示例14: askSaveAsFilename

def askSaveAsFilename(filetypes=None, initialfile=None):
    " returns empty string if unsuccessful"
    ft = []
    if filetypes != None:
        ft.append( (filetypes,filetypes )) # "*.dat" --> ("*.dat", "*.dat")
    if initialfile == None:
        f = asksaveasfilename(filetypes=ft)
    else:
        f = asksaveasfilename(filetypes=ft, initialfile=initialfile)
    if type(f) == type(()):
        return ""
    else:
        #f = string.replace(f,"/tmp_mnt","")
        return f
开发者ID:spider-em,项目名称:SPIDER,代码行数:14,代码来源:spiderGUtils.py

示例15: save_network

 def save_network(self,type="square"):
     network=self.distancematrix
     netfilename=tkFileDialog.asksaveasfilename(title="Select file for the distance matrix")
     if len(netfilename)==0:
         return
     netfile=open(netfilename,"w")
     nodes=netio.writeNet_mat(network,netfile,type=type)
     nodefilename=tkFileDialog.asksaveasfilename(title="Select file for node names")
     if len(nodefilename)>0:
         nodefile=open(nodefilename,"w")
         for node in nodes:
             nodefile.write(str(node)+"\n")
         tkMessageBox.showinfo(message='Save succesful.')
     else:
         tkMessageBox.showinfo(message='Save succesful.\nNode names not saved.')
开发者ID:bolozna,项目名称:EDENetworks,代码行数:15,代码来源:RawDataWindow.py


注:本文中的tkFileDialog.asksaveasfilename函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。