本文整理汇总了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()
示例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())
示例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:
示例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
示例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)
示例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)
示例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))
示例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