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


Python tkFileDialog.askopenfilename方法代码示例

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


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

示例1: flash

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfilename [as 别名]
def flash(self):
        self.fl_state.set("Processing...")
        filename = askopenfilename(
            filetypes=((_("Flash"), "*.bin"), (_("All files"), "*.*"))
        )
        if filename == "":
            return
        if len(self.table.selection()) == 0:
            _mac = "all"
        else:
            _mac = self.table.item(self.table.selection()[0], option="values")[4]
        result = ProcessCMD(
            ["flash", _mac, self.passw.get(), filename, self.fl_state.set]
        )
        if (
            hasattr(result, "keys")
            and "Ret" in result.keys()
            and result["Ret"] in CODES.keys()
        ):
            showerror(_("Error"), CODES[result["Ret"]]) 
开发者ID:NeiroNx,项目名称:python-dvr,代码行数:22,代码来源:DeviceManager.py

示例2: load_chart

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfilename [as 别名]
def load_chart(self, *args):
        "Load a chart from a pickle file"
        filename = askopenfilename(filetypes=self.CHART_FILE_TYPES,
                                   defaultextension='.pickle')
        if not filename: return
        try:
            chart = pickle.load(open(filename, 'r'))
            self._chart = chart
            self._cv.update(chart)
            if self._matrix: self._matrix.set_chart(chart)
            if self._matrix: self._matrix.deselect_cell()
            if self._results: self._results.set_chart(chart)
            self._cp.set_chart(chart)
        except Exception, e:
            raise
            tkMessageBox.showerror('Error Loading Chart',
                                   'Unable to open file: %r' % filename) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:19,代码来源:chart.py

示例3: loadTypetoTarget

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfilename [as 别名]
def loadTypetoTarget(self, fileType, targetWindow, ftype = None):
    	
    	if not (fileType and targetWindow): return
    	
    	from tkFileDialog import askopenfilename
        ftypes = [(fileType, fileType)]

        filename = askopenfilename(filetypes=ftypes, defaultextension=fileType)

        self.loadIntoWindow(filename, targetWindow)

        # set the config menu to blank
        self.configsMenuButton.configure(text='<none>')

        # !!! remember to reset all the filenames as well!
        if filename:
        	if ftype == 'l': self.lexfilename = filename
        	elif ftype == 'r': self.rulfilename = filename 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:20,代码来源:kimmo.py

示例4: print_welcome

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfilename [as 别名]
def print_welcome():

    print("\n\n=======================================================================")
    print("Hello there, I am the going to help you plot LSDTopoTools data!")
    print("You will need to tell me where the parameter file is.")
    print("Use the -wd flag to define the working directory.")
    print("If you dont do this I will assume the data is in the same directory as this script.")
    print("=======================================================================\n\n ")

    from Tkinter import Tk
    from tkFileDialog import askopenfilename

    Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
    filename = askopenfilename() # show an "Open" dialog box and return the path to the selected file
    
    return filename    
   
    
    
#============================================================================= 
开发者ID:LSDtopotools,项目名称:LSDMappingTools,代码行数:22,代码来源:MappingDriver.py

示例5: browse_directory

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfilename [as 别名]
def browse_directory(self, option):
        if option == "pcap":
            # Reference: http://effbot.org/tkinterbook/tkinter-dialog-windows.htm
            self.pcap_file.set(fd.askopenfilename(initialdir = sys.path[0],title = "Select Packet Capture File!",filetypes = (("All","*.pcap *.pcapng"),("pcap files","*.pcap"),("pcapng files","*.pcapng"))))
            self.filename = self.pcap_file.get().replace(".pcap","")
            if "/" in self.filename:
                self.filename = self.filename.split("/")[-1]
            #,("all files","*.*")
            #self.filename_field.delete(0, END)
            #self.filename_field.insert(0, self.pcap_file)
            print(self.filename)
            print(self.pcap_file)
        else:
            self.destination_report.set(fd.askdirectory())
            if self.destination_report.get():
                if not os.access(self.destination_report.get(), os.W_OK):
                    mb.showerror("Error","Permission denied to create report! Run with higher privilege.")
            else:
                mb.showerror("Error", "Enter a output directory!") 
开发者ID:Srinivas11789,项目名称:PcapXray,代码行数:21,代码来源:user_interface.py

示例6: main

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfilename [as 别名]
def main():
    base = Tk()
    base.title("ms_deisotope Spectrum Viewer")
    tk.Grid.rowconfigure(base, 0, weight=1)
    tk.Grid.columnconfigure(base, 0, weight=1)
    app = SpectrumViewer(base)
    app.do_layout()

    try:
        fname = sys.argv[1]
    except IndexError:
        fname = None
        # fname = tkfiledialog.askopenfilename()
    print("initial value", fname)
    app.ms_file_name = fname

    app.mainloop() 
开发者ID:mobiusklein,项目名称:ms_deisotope,代码行数:19,代码来源:view.py

示例7: browse_file

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfilename [as 别名]
def browse_file(self):

    	self.fname = tkFileDialog.askopenfilename(filetypes = (("Template files", "*.type"), ("All files", "*")))
                
#     def submit(self):
#         print('Name: {}'.format(self.entry_name.get()))
#         print('Email: {}'.format(self.entry_email.get()))
#         print('Comments: {}'.format(self.text_comments.get(1.0, 'end')))
#         self.clear()
#         tkMessageBox.showinfo(title = 'Explore California Feedback', message = 'Comments Submitted!')
#                             
#     def clear(self):
#         self.entry_name.delete(0, 'end')
#         self.entry_email.delete(0, 'end')
#         self.text_comments.delete(1.0, 'end')
# 
开发者ID:hiteshchoudhary,项目名称:Airvengers,代码行数:18,代码来源:Airtun-ng.py

示例8: AskShapefilePath

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfilename [as 别名]
def AskShapefilePath(text="unknown task"):
    """
Pops up a temporary tk window asking user to visually choose a shapefile.
Returns the chosen shapefile path as a text string. Also prints it as text in case
the user wants to remember which shapefile was picked and hardcode it in the script.

| __option__ | __description__ 
| --- | --- 
| *text | an optional string to identify what purpose the shapefile was chosen for when printing the result as text.
"""
    tempwindow = tk.Tk()
    tempwindow.state("withdrawn")
    shapefilepath = tkFileDialog.askopenfilename(parent=tempwindow, filetypes=[("shapefile",".shp")], title="choose shapefile for "+text)
    tempwindow.destroy()
    print("you picked the following shapefile for <"+str(text)+">:\n"+str(shapefilepath)+"\n\n")
    return shapefilepath 
开发者ID:karimbahgat,项目名称:GeoVis,代码行数:18,代码来源:__init__.py

示例9: load_file

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfilename [as 别名]
def load_file(self, file=None):

        if file is None:
            file = tkfiledialog.askopenfilename(filetypes=[('GCode files', '.nc'), ('all files','.*')])
            self.filepath = file.rsplit('/',1)[0]  # save file path without the file name
            if file:
                try:
                    data = open(file, 'rb')
                except Exception as details:
                    tkmessagebox.showerror(('Error'),details)
                    return
        else:
            try:
                data = open(file, 'rb')
            except Exception as details:
                print(details)
                return
        self.file = data 
开发者ID:meco-group,项目名称:omg-tools,代码行数:20,代码来源:gcode_reader.py

示例10: load_settings

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfilename [as 别名]
def load_settings(self, s=None):
        """Load a perferences settings."""
        if s is None:
            if self.restore_last_pref:
                self.restore_last_pref = False
                if not os.path.isdir(self.default_path_to_pref):
                    return
                path_to_pref = os.path.join(self.default_path_to_pref,
                                            '_last_settings.json')
                if not os.path.isfile(path_to_pref):
                    return
            else:
                path_to_pref = filedialog.askopenfilename(
                    defaultextension='.json', filetypes=[("json files",
                                                          '*.json')],
                    initialdir=self.default_path_to_pref,
                    title="Choose filename")
            s = json.load(open(path_to_pref))
        self.set_preferences(s) 
开发者ID:NeuromorphicProcessorProject,项目名称:snn_toolbox,代码行数:21,代码来源:gui.py

示例11: open_existing

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfilename [as 别名]
def open_existing(self, *args):
    
        filename = tkFileDialog.askopenfilename()
        
        extension = filename.split('.')[-1]
        
        
        if filename is None:
            return
        elif extension not in ['strapbm']:
            tkMessageBox.showerror("ERROR!!","Selected File not a .strapbm file")
            return
        else:
            calc_file = open(filename,'r')
            calc_data = calc_file.readlines()
            calc_file.close()
            
            i=0
            for line in calc_data:
                value = line.rstrip('\n')
                self.inputs[i].set(value)
                i+=1 
开发者ID:buddyd16,项目名称:Structural-Engineering,代码行数:24,代码来源:strap_beam_gui.py

示例12: load_script

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfilename [as 别名]
def load_script(self):
        """load a script file, ask validation of detected Python code"""
        filename = filedialog.askopenfilename(
            initialdir=self.initialdir, defaultextension='.sql',
            filetypes=[("default", "*.sql"), ("other", "*.txt"),
                       ("all", "*.*")])
        if filename != '':
            self.set_initialdir(filename)
            text = os.path.split(filename)[1].split(".")[0]
            with io.open(filename, encoding=guess_encoding(filename)[0]) as f:
                script = f.read()
                sqls = self.conn.get_sqlsplit(script, remove_comments=True)
                dg = [s for s in sqls if s.strip(' \t\n\r')[:5] == "pydef"]
                if dg:
                    fields = ['', ['In Script File:', filename, 'r', 100], '',
                              ["Python Script", "".join(dg), 'r', 80, 20]]

                    create_dialog(("Ok for this Python Code ?"), fields,
                                  ("Confirm", self.load_script_ok),
                                  [text, script])
                else:
                    new_tab_ref = self.n.new_query_tab(text, script) 
开发者ID:stonebig,项目名称:sqlite_bro,代码行数:24,代码来源:sqlite_bro.py

示例13: attach_db

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfilename [as 别名]
def attach_db(self):
        """attach an existing database"""
        filename = filedialog.askopenfilename(
            initialdir=self.initialdir, defaultextension='.db',
            title="Choose a database to attach ",
            filetypes=[("default", "*.db"), ("other", "*.db*"),
                       ("all", "*.*")])
        attach = os.path.basename(filename).split(".")[0]
        avoid = {i[1]: 0 for i in get_leaves(self.conn, 'attached_databases')}
        att, indice = attach, 0
        while attach in avoid:
            attach, indice = att + "_" + str(indice), indice + 1
        if filename != '':
            self.set_initialdir(filename)
            attach_order = "ATTACH DATABASE '%s' as '%s' " % (filename, attach)
            self.conn.execute(attach_order)
            self.actualize_db() 
开发者ID:stonebig,项目名称:sqlite_bro,代码行数:19,代码来源:sqlite_bro.py

示例14: load_chart_dialog

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfilename [as 别名]
def load_chart_dialog(self, *args):
        filename = askopenfilename(filetypes=self.CHART_FILE_TYPES,
                                   defaultextension='.pickle')
        if not filename: return
        try: self.load_chart(filename)
        except Exception, e:
            tkMessageBox.showerror('Error Loading Chart',
                                   'Unable to open file: %r\n%s' %
                                   (filename, e)) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:11,代码来源:chart.py

示例15: load_grammar

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfilename [as 别名]
def load_grammar(self, *args):
        "Load a grammar from a pickle file"
        filename = askopenfilename(filetypes=self.GRAMMAR_FILE_TYPES,
                                   defaultextension='.cfg')
        if not filename: return
        try:
            if filename.endswith('.pickle'):
                grammar = pickle.load(open(filename, 'r'))
            else:
                grammar = cfg.parse_grammar(open(filename, 'r').read())
            self.set_grammar(grammar)
        except Exception, e:
            tkMessageBox.showerror('Error Loading Grammar', 
                                   'Unable to open file: %r' % filename) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:16,代码来源:chart.py


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