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


Python tkFileDialog.askopenfile方法代码示例

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


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

示例1: loadPrefs

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfile [as 别名]
def loadPrefs( self ):
        "Load command."
        c = self.canvas

        myFormats = [
            ('Config File','*.config'),
            ('All Files','*'),
        ]
        f = tkFileDialog.askopenfile(filetypes=myFormats, mode='rb')
        if f == None:
            return

        loadedPrefs = self.convertJsonUnicode(json.load(f))
        # Load application preferences
        if 'preferences' in loadedPrefs:
            self.appPrefs = dict(self.appPrefs.items() + loadedPrefs['preferences'].items())
        # Load application filters
        if 'filters' in loadedPrefs:
            self.appFilters = dict(self.appFilters.items() + loadedPrefs['filters'].items())
        f.close() 
开发者ID:uccmisl,项目名称:MiniNAM,代码行数:22,代码来源:MiniNAM.py

示例2: load_config

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfile [as 别名]
def load_config(self, filename=None):
        if filename is None:
            file_obj = tkFileDialog.askopenfile()
            if file_obj is None: return
        else:
            file_obj = open(filename, 'r')
        try:
            load_config(file_obj, self.lens1, self.lens2)
        except:
            tkMessageBox.showerror('Config load error', traceback.format_exc()) 
开发者ID:ooterness,项目名称:DualFisheye,代码行数:12,代码来源:fisheye.py

示例3: _file_select

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfile [as 别名]
def _file_select(self, tkstr):
        result = tkFileDialog.askopenfile()
        if result is not None:
            tkstr.set(result.name)
            result.close()

    # Make a combined label/textbox/slider for a given variable: 
开发者ID:ooterness,项目名称:DualFisheye,代码行数:9,代码来源:fisheye.py

示例4: __init__

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfile [as 别名]
def __init__(self):
        data_dir = user_data_dir('sky3ds', 'Aperture Laboratories')
        template_txt = os.path.join(data_dir, 'template.txt')

        file_name = tkFileDialog.askopenfile( initialdir = os.path.expanduser('~/Desktop'), filetypes=[ ("Text files","*.txt")] )

        if file_name:
            try:
                new_template = file_name.read()
                write_template = open(template_txt, 'w')
                write_template.write(new_template)

                file_name.close()
                write_template.close()

                tkMessageBox.showinfo("Template Updated", "Template.txt updated successfully")

            except:
                raise Exception("Template.txt could not be updated")

            try:
                titles.convert_template_to_json()
            except:
                raise Exception("Template.txt could not converted to JSON. Please verify that your template.txt is not corrupt.")
        else:
            return 
开发者ID:lukas2511,项目名称:sky3ds.py,代码行数:28,代码来源:gui.py

示例5: loadFighter

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfile [as 别名]
def loadFighter(self):
        fighter_file = askopenfile(mode="r",initialdir=settingsManager.createPath('fighters'),filetypes=[('TUSSLE Fighters','*.xml'),('Advanced Fighters', '*.py')])
        self.root.fighter_file = fighter_file
        self.root.fighter_properties = fighter_file.read()
        self.root.fighter_string.set(fighter_file.name)
        self.entryconfig("Action", state=NORMAL) 
开发者ID:digiholic,项目名称:universalSmashSystem,代码行数:8,代码来源:builderWindow.py

示例6: pickFile

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfile [as 别名]
def pickFile(self,_resultVar, _filetype='file', _extensions=[]):
        if _filetype == 'file':
            loaded_file = askopenfile(mode="r",
                               initialdir=settingsManager.createPath('fighters'),
                               filetypes=_extensions)
            loaded_name = loaded_file.name
        elif _filetype == 'dir':
            loaded_name = askdirectory(initialdir=settingsManager.createPath(''))
        res = os.path.relpath(loaded_name,os.path.dirname(self.root.root.fighter_file.name))
        _resultVar.set(res) 
开发者ID:digiholic,项目名称:universalSmashSystem,代码行数:12,代码来源:subactionSelector.py

示例7: loadImage

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfile [as 别名]
def loadImage(self):
        if self.target_object:
            imgfile = askopenfile(mode="r",initialdir=self.target_object.base_dir,filetypes=[('Image Files','*.png')])
            self.image_data.set(os.path.relpath(imgfile.name, self.target_object.base_dir)) 
开发者ID:digiholic,项目名称:universalSmashSystem,代码行数:6,代码来源:dataSelector.py

示例8: showfilebrowser

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askopenfile [as 别名]
def showfilebrowser(self):
        import tkFileDialog
        file = tkFileDialog.askopenfile()
        try:
            #Only do something if a file has been selected.
            if file.name:
                self.textentry.delete(0,255)
                self.textentry.insert(0, file.name)
        except:
            #If no file has been selected do nothing.
            pass 
开发者ID:igp-gravity,项目名称:geoist,代码行数:13,代码来源:gimodule.py


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