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


Python tkinter.filedialog方法代码示例

本文整理汇总了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]) 
开发者ID:YoannDupont,项目名称:SEM,代码行数:10,代码来源:components.py

示例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 
开发者ID:pelednoam,项目名称:mmvt,代码行数:14,代码来源:setup_utils.py

示例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) 
开发者ID:YoannDupont,项目名称:SEM,代码行数:6,代码来源:annotation_gui.py

示例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) 
开发者ID:YoannDupont,项目名称:SEM,代码行数:13,代码来源:annotation_gui.py

示例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") 
开发者ID:YoannDupont,项目名称:SEM,代码行数:5,代码来源:annotation_gui.py

示例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") 
开发者ID:YoannDupont,项目名称:SEM,代码行数:5,代码来源:annotation_gui.py

示例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") 
开发者ID:YoannDupont,项目名称:SEM,代码行数:5,代码来源:annotation_gui.py

示例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
    # 
开发者ID:YoannDupont,项目名称:SEM,代码行数:9,代码来源:annotation_gui.py

示例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) 
开发者ID:YoannDupont,项目名称:SEM,代码行数:8,代码来源:annotation_gui.py

示例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) 
开发者ID:YoannDupont,项目名称:SEM,代码行数:11,代码来源:components.py

示例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)) 
开发者ID:LaboratoireMecaniqueLille,项目名称:crappy,代码行数:34,代码来源:cameralink.py

示例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() 
开发者ID:pvlib,项目名称:pvlib-python,代码行数:7,代码来源:tmy.py

示例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() 
开发者ID:irmen,项目名称:synthesizer,代码行数:10,代码来源:gui.py

示例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() 
开发者ID:TheresAFewConors,项目名称:Sooty,代码行数:12,代码来源:Sooty.py

示例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() 
开发者ID:TheresAFewConors,项目名称:Sooty,代码行数:33,代码来源:Sooty.py


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