當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。