• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tkFileDialog.asksaveasfilename函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: save_iso2flux_model

def save_iso2flux_model(label_model,name="project",write_sbml=True,ask_sbml_name=False,gui=False):
   project_name=name
   if gui:
      tk=Tkinter.Tk()
      tk.withdraw()
      project_name = tkFileDialog.asksaveasfilename(parent=tk,title="Save project as...",filetypes=[("iso2flux",".iso2flux")])
      if ".iso2flux" not in project_name:
        project_name+=".iso2flux"
      if write_sbml and ask_sbml_name:
         sbml_name=tkFileDialog.asksaveasfilename(parent=tk,title="Save reference SBML model as...",filetypes=[("sbml",".sbml"),("xml",".xml")])
         if ".sbml" not in sbml_name:
           sbml_name+=".sbml"
      tk.destroy()
   project_dict={}
   #project_dict["condition_size_yy_dict"]=label_model.condition_size_yy_dict
   #project_dict["condition_size_yy0_dict"]=label_model.condition_size_yy0_dict
   project_dict["eqn_dir"]=label_model.eqn_dir
   project_dict["reaction_n_dict"]=label_model.reaction_n_dict
   project_dict["merged_reactions_reactions_dict"]=label_model.merged_reactions_reactions_dict
   project_dict["force_balance"]=label_model.force_balance
   project_dict["ratio_dict"]=label_model.ratio_dict
   project_dict["parameter_dict"]=label_model.parameter_dict
   project_dict["turnover_flux_dict"]=label_model.turnover_flux_dict
   project_dict["size_variable_dict"]=label_model.size_variable_dict
   project_dict["emu_dict"]=label_model.emu_dict
   project_dict["rsm_list"]=label_model.rsm_list
   project_dict["emu_size_dict"]=label_model.emu_size_dict
   project_dict["initial_label"]=label_model.initial_label
   project_dict["experimental_dict"]=label_model.experimental_dict
   project_dict["input_m0_list"]=label_model.input_m0_list
   project_dict["input_n_dict"]=label_model.input_n_dict
   project_dict["data_name_emu_dict"]=label_model.data_name_emu_dict
   project_dict["lp_tolerance_feasibility"]=label_model.lp_tolerance_feasibility
   project_dict["parameter_precision"]=label_model.parameter_precision
   project_dict["metabolite_id_isotopomer_id_dict"]=label_model.metabolite_id_isotopomer_id_dict
   project_dict["isotopomer_id_metabolite_id_dict"]=label_model.isotopomer_id_metabolite_id_dict
   project_dict["reactions_propagating_label"]=label_model.reactions_propagating_label
   project_dict["label_groups_reactions_dict"]=label_model.label_groups_reactions_dict
   #project_dict["label_groups_reactions_dict"]=label_model.label_groups_reactions_dict
   project_dict["p_dict"]=label_model.p_dict
   if write_sbml:
      if ask_sbml_name==False or gui==False:
         sbml_name=project_name[:-9]+"_iso2flux.sbml"
      cobra.io.write_sbml_model(label_model.metabolic_model, sbml_name)
   with open(project_name, 'w') as fp:
         json.dump(project_dict, fp)
   label_model.project_name=project_name.split("/")[-1]
   return project_name
开发者ID:pcm32,项目名称:iso2flux,代码行数:48,代码来源:save_load_iso2flux_model.py


示例17: _save

    def _save(self, *argv):
        if not self._preview(): return
        self.consoleNor("过程控制:图片正在处理中...")
        filepath = tkFileDialog.asksaveasfilename()

        filename = os.path.basename(filepath)
        dotNum = filename.count(".")

        if dotNum == 0:
            if filename == "" : return
            postfix = ".jpg"
        elif dotNum >= 2 or not (filename.split(".")[1] in IMAGE_TYPES):
            self.consoleErr("格式错误:文件名格式错误!")
            return
        else:
            postfix = ""

        if os.path.exists(self.filename) and fileCheck.isImage(self.filename):
            try:
                if self.algNum == 0:
                    im = tool_cv2.resize_linear(self.filename, self.wScale, self.hScale)
                else:
                    im = tool_cv2.resize_cubic(self.filename, self.wScale, self.hScale)
                self.consoleNor("过程控制:图片处理完毕,开始保存...")
                cv2.imwrite(filepath+postfix, im)
                self.consoleNor("过程控制:图片保存完毕...")
            except:
                self.consoleErr("过程控制:图片保存过程出现问题...")
        else:
            self.consoleErr("类型错误:打开的不是图片或者是文件不存在!")
开发者ID:KaiHangYang,项目名称:calMethod,代码行数:30,代码来源:start.py


示例18: save_text

 def save_text(self):
     fname = tkFileDialog.asksaveasfilename()
     f = open(fname, "wb")
     for v in self.shot_dict.values():
         line = "%s\n" % v
         f.write(line)
     pass
开发者ID:JulianJaffe,项目名称:ShotTracker,代码行数:7,代码来源:shot_tracker.py


示例19: report

    def report(self):
        '''
        generate the report, run by clicking Button
        '''
        if self.year.get() is '':
            self.output_text("! - Please Select a Year")
            return
        if self.month.get() is '':
            self.output_text("! - Please select a Month")
            return

        year = self.year.get()
        inputf = 'jim_data' + year + '.xlsx'
        month = self.month.get()
        outputf_def = month + year + '_report.xlsx'
        outputf = tkFileDialog.asksaveasfilename(parent=self,
            defaultextension='.xlsx', initialfile=outputf_def)
        if outputf is '': return #file not selected

        #output report
        month_report(inputf,month,year,outputf,self.customers,self.payments)

        self.output_text("* - " + self.month.get() + ' ' + self.year.get() + ' report saved to: ' + outputf + '\n')

        # print stat(outputf)

        if sys.platform == 'darwin':
            system('open ' + outputf + ' &')
        else:
            system(outputf) # open the file
开发者ID:tylerjw,项目名称:jim_tracker,代码行数:30,代码来源:reports.py


示例20: onSave

 def onSave(self):
     file_opt = options = {}
     options['filetypes'] = [('Image Files', '*.tif *.jpg *.png')]
     options['initialfile'] = 'myImage.jpg'
     options['parent'] = self.parent
     fname = tkFileDialog.asksaveasfilename(**file_opt)
     Image.fromarray(np.uint8(self.Ilast)).save(fname)
开发者ID:bistaumanga,项目名称:DIP_Algorithms,代码行数:7,代码来源:main.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tkFont.nametofont函数代码示例发布时间:2022-05-27
下一篇:
Python tkFileDialog.asksaveasfile函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap