本文整理匯總了Python中tkinter.filedialog方法的典型用法代碼示例。如果您正苦於以下問題:Python tkinter.filedialog方法的具體用法?Python tkinter.filedialog怎麽用?Python tkinter.filedialog使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tkinter
的用法示例。
在下文中一共展示了tkinter.filedialog方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: filenames
# 需要導入模塊: import tkinter [as 別名]
# 或者: from tkinter import filedialog [as 別名]
def filenames(self, event=None):
self.current_files = list(tkinter.filedialog.askopenfilenames(**self.file_opt))
self.current_files.sort(key=lambda x:x.lower())
self.selected_files.delete(0, tkinter.END)
if self.current_files:
for current_file in self.current_files:
self.selected_files.insert(tkinter.END, os.path.basename(current_file))
self.file_opt['initialdir'] = os.path.dirname(self.current_files[0])
示例2: choose_folder_gui
# 需要導入模塊: import tkinter [as 別名]
# 或者: from tkinter import filedialog [as 別名]
def choose_folder_gui(initialdir='', title=''):
import tkinter
from tkinter.filedialog import askdirectory
root = tkinter.Tk()
root.withdraw() # hide root
if initialdir != '':
fol = askdirectory(initialdir=initialdir, title=title)
else:
fol = askdirectory(title=title)
if is_windows():
fol = fol.replace('/', '\\')
return fol
示例3: openfile_gui
# 需要導入模塊: import tkinter [as 別名]
# 或者: from tkinter import filedialog [as 別名]
def openfile_gui(self, event=None):
filenames = tkinter.filedialog.askopenfilenames(filetypes=[("SEM readable files", (".txt", ".sem.xml", ".sem", ".ann")), ("text files", ".txt"), ("BRAT files", (".txt", ".ann")), ("SEM XML files", ("*.sem.xml", ".sem")), ("All files", ".*")])
if filenames == []: return
self.openfile(filenames)
示例4: save
# 需要導入模塊: import tkinter [as 別名]
# 或者: from tkinter import filedialog [as 別名]
def save(self, event=None):
filename = tkinter.filedialog.asksaveasfilename(defaultextension=".sem.xml")
if filename == u"": return
self.unselect()
if self.doc_is_modified:
update_annotations(self.doc, self.annotation_name, self.current_annotations.annotations)
corpus = SEMCorpus(documents=self.corpus_documents)
with codecs.open(filename, "w", "utf-8") as O:
corpus.write(O)
示例5: save_brat
# 需要導入模塊: import tkinter [as 別名]
# 或者: from tkinter import filedialog [as 別名]
def save_brat(self, event=None):
output_directory = tkinter.filedialog.askdirectory(initialdir=sem.SEM_DATA_DIR)
self.save_as_format(output_directory, "brat")
示例6: save_gate
# 需要導入模塊: import tkinter [as 別名]
# 或者: from tkinter import filedialog [as 別名]
def save_gate(self, event=None):
output_directory = tkinter.filedialog.askdirectory(initialdir=sem.SEM_DATA_DIR)
self.save_as_format(output_directory, "gate")
示例7: save_tei_analec
# 需要導入模塊: import tkinter [as 別名]
# 或者: from tkinter import filedialog [as 別名]
def save_tei_analec(self, event=None):
output_directory = tkinter.filedialog.askdirectory(initialdir=sem.SEM_DATA_DIR)
self.save_as_format(output_directory, "tei_analec")
示例8: save_json
# 需要導入模塊: import tkinter [as 別名]
# 或者: from tkinter import filedialog [as 別名]
def save_json(self, event=None):
output_directory = tkinter.filedialog.askdirectory(initialdir=sem.SEM_DATA_DIR)
self.save_as_format(output_directory, "jason")
#
# Edit menu methods
#
示例9: load_tagset_gui
# 需要導入模塊: import tkinter [as 別名]
# 或者: from tkinter import filedialog [as 別名]
def load_tagset_gui(self, event=None):
filename = tkinter.filedialog.askopenfilename(filetypes=[("text files", ".txt"), ("All files", ".*")], initialdir=os.path.join(sem.SEM_DATA_DIR, "resources", "tagsets"))
if len(filename) == 0: return
self.load_tagset(filename)
示例10: select_file
# 需要導入模塊: import tkinter [as 別名]
# 或者: from tkinter import filedialog [as 別名]
def select_file(self, event=None):
options = {}
options['defaultextension'] = '.txt'
options['filetypes'] = [('all files', '.*'), ('text files', '.txt')]
options['initialdir'] = os.path.join(sem.SEM_DATA_DIR, "resources", "patterns")
options['parent'] = self.trainTop
options['title'] = 'Select pattern file.'
pattern = tkinter.filedialog.askopenfilename(**options)
self.pattern_label_var.set(pattern)
示例11: __init__
# 需要導入模塊: import tkinter [as 別名]
# 或者: from tkinter import filedialog [as 別名]
def __init__(self, numdevice=0, config_file=None, camera_type=None):
"""Using the clModule, will open a cameraLink camera.
If a config file is specified, it will be used to configure the camera
If not set, it will be asked, unless set to False (or 0)
Else, you must at least provide the camera type (eg: "FullAreaGray8")
Using a config file is recommended over changing all settings manually
"""
#print("config_file:",config_file)
Camera.__init__(self)
self.config_file = config_file
self.camera_type = camera_type
if config_file is None:
import tkinter
import tkinter.filedialog
root = tkinter.Tk()
root.withdraw()
self.config_file = tkinter.filedialog.askopenfilename(parent=root)
root.destroy()
if self.camera_type is None and self.config_file:
with open(self.config_file,'r') as f:
r = f.readlines()
r = [s for s in r if s[:5]=="Typ='"]
if len(r) != 0:
self.camera_type = r[0][5:-3]
if self.camera_type is None:
raise AttributeError("No camera type or valid config file specified!")
self.name = "cl_camera"
self.numdevice = numdevice
self.add_setting("width",setter=self._set_w, getter=self._get_w)
self.add_setting("height",setter=self._set_h, getter=self._get_h)
self.add_setting("framespersec",setter=self._set_framespersec,
getter=self._get_framespersec,limits=(1,200))
示例12: _interactive_load
# 需要導入模塊: import tkinter [as 別名]
# 或者: from tkinter import filedialog [as 別名]
def _interactive_load():
import tkinter
from tkinter.filedialog import askopenfilename
tkinter.Tk().withdraw() # Start interactive file input
return askopenfilename()
示例13: start
# 需要導入模塊: import tkinter [as 別名]
# 或者: from tkinter import filedialog [as 別名]
def start(self, samples_location: str):
self.messages.insert(tkinter.END, "~~~~ Python DrumKit ~~~~\n")
if not os.path.isdir(samples_location):
print(">>>> Select the directory contaiting the Salamander Drumkit v1 files <<<<")
samples_location = tkinter.filedialog.askdirectory()
import threading
threading.Thread(target=self.load_drumkit, args=(samples_location,)).start()
self.mainloop()
示例14: hashFile
# 需要導入模塊: import tkinter [as 別名]
# 或者: from tkinter import filedialog [as 別名]
def hashFile():
root = tkinter.Tk()
root.filename = tkinter.filedialog.askopenfilename(initialdir="/", title="Select file")
hasher = hashlib.md5()
with open(root.filename, 'rb') as afile:
buf = afile.read()
hasher.update(buf)
print(" MD5 Hash: " + hasher.hexdigest())
root.destroy()
hashMenu()
示例15: hashAndFileUpload
# 需要導入模塊: import tkinter [as 別名]
# 或者: from tkinter import filedialog [as 別名]
def hashAndFileUpload():
root = tkinter.Tk()
root.filename = tkinter.filedialog.askopenfilename(initialdir="/", title="Select file")
hasher = hashlib.md5()
with open(root.filename, 'rb') as afile:
buf = afile.read()
hasher.update(buf)
fileHash = hasher.hexdigest()
print(" MD5 Hash: " + fileHash)
root.destroy()
apierror = False
# VT Hash Checker
url = 'https://www.virustotal.com/vtapi/v2/file/report'
params = {'apikey': configvars.data['VT_API_KEY'], 'resource': fileHash}
response = requests.get(url, params=params)
try: # EAFP
result = response.json()
except:
apierror = True
print("Error: Invalid API Key")
if not apierror:
if result['response_code'] == 0:
print("\n Hash was not found in Malware Database")
elif result['response_code'] == 1:
print(" VirusTotal Report: " + str(result['positives']) + "/" + str(result['total']) + " detections found")
print(" Report Link: " + "https://www.virustotal.com/gui/file/" + fileHash + "/detection")
else:
print("No Response")
hashMenu()