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


Python tkFileDialog.askdirectory方法代码示例

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


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

示例1: browse_directory

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askdirectory [as 别名]
def browse_directory(self, option):
        if option == "pcap":
            # Reference: http://effbot.org/tkinterbook/tkinter-dialog-windows.htm
            self.pcap_file.set(fd.askopenfilename(initialdir = sys.path[0],title = "Select Packet Capture File!",filetypes = (("All","*.pcap *.pcapng"),("pcap files","*.pcap"),("pcapng files","*.pcapng"))))
            self.filename = self.pcap_file.get().replace(".pcap","")
            if "/" in self.filename:
                self.filename = self.filename.split("/")[-1]
            #,("all files","*.*")
            #self.filename_field.delete(0, END)
            #self.filename_field.insert(0, self.pcap_file)
            print(self.filename)
            print(self.pcap_file)
        else:
            self.destination_report.set(fd.askdirectory())
            if self.destination_report.get():
                if not os.access(self.destination_report.get(), os.W_OK):
                    mb.showerror("Error","Permission denied to create report! Run with higher privilege.")
            else:
                mb.showerror("Error", "Enter a output directory!") 
开发者ID:Srinivas11789,项目名称:PcapXray,代码行数:21,代码来源:user_interface.py

示例2: filebrowse

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askdirectory [as 别名]
def filebrowse(self, title, pathvar):
        if platform != 'win32':
            import tkFileDialog
            d = tkFileDialog.askdirectory(parent=self, initialdir=expanduser(pathvar.get()), title=title, mustexist=tk.TRUE)
        else:
            def browsecallback(hwnd, uMsg, lParam, lpData):
                # set initial folder
                if uMsg==BFFM_INITIALIZED and lpData:
                    ctypes.windll.user32.SendMessageW(hwnd, BFFM_SETSELECTION, 1, lpData);
                return 0

            browseInfo = BROWSEINFO()
            browseInfo.lpszTitle = title
            browseInfo.ulFlags = BIF_RETURNONLYFSDIRS|BIF_USENEWUI
            browseInfo.lpfn = BrowseCallbackProc(browsecallback)
            browseInfo.lParam = pathvar.get().startswith('~') and join(config.home, pathvar.get()[2:]) or pathvar.get()
            ctypes.windll.ole32.CoInitialize(None)
            pidl = ctypes.windll.shell32.SHBrowseForFolderW(ctypes.byref(browseInfo))
            if pidl:
                path = ctypes.create_unicode_buffer(MAX_PATH)
                ctypes.windll.shell32.SHGetPathFromIDListW(pidl, path)
                ctypes.windll.ole32.CoTaskMemFree(pidl)
                d = path.value
            else:
                d = None

        if d:
            pathvar.set(d)
            self.outvarchanged() 
开发者ID:EDCD,项目名称:EDMarketConnector,代码行数:31,代码来源:prefs.py

示例3: diropenbox

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askdirectory [as 别名]
def diropenbox(msg=None
    , title=None
    , default=None
    ):
    """
    A dialog to get a directory name.
    Note that the msg argument, if specified, is ignored.

    Returns the name of a directory, or None if user chose to cancel.

    If the "default" argument specifies a directory name, and that
    directory exists, then the dialog box will start with that directory.
    """
    title=getFileDialogTitle(msg,title)
    boxRoot = Tk()
    boxRoot.withdraw()
    if not default: default = None
    f = tk_FileDialog.askdirectory(
          parent=boxRoot
        , title=title
        , initialdir=default
        , initialfile=None
        )
    boxRoot.destroy()
    if not f: return None
    return os.path.normpath(f)



#-------------------------------------------------------------------
# getFileDialogTitle
#------------------------------------------------------------------- 
开发者ID:mantarayforensics,项目名称:mantaray,代码行数:34,代码来源:easygui.py

示例4: askdirectory

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askdirectory [as 别名]
def askdirectory(self):

        # removes the message from the grid
        self.messageView.grid_forget()

        """Returns a selected directory name."""
        self.dirname = tkFileDialog.askdirectory(**self.dir_opt)
        self.entryVariable.set(self.dirname)
        self.buttonView.configure(state=NORMAL)
        return self.dirname 
开发者ID:aces,项目名称:DICAT,代码行数:12,代码来源:dicom_anonymizer_frame.py

示例5: askDir

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askdirectory [as 别名]
def askDir(self):
        dirname = filedialog.askdirectory()
        self.dir_name.set(dirname)
        self.loadDir(dirname) 
开发者ID:NVIDIA-AI-IOT,项目名称:GreenMachine,代码行数:6,代码来源:gui.py

示例6: get_plugin_dir

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askdirectory [as 别名]
def get_plugin_dir(self):
        self.plugin_dir_path.set(tkFileDialog.askdirectory()) 
开发者ID:nanoleaf,项目名称:aurora-sdk-mac,代码行数:4,代码来源:main.py

示例7: select_folder

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askdirectory [as 别名]
def select_folder():
    root = Tk()
    root.withdraw()
    path = realpath(askdirectory(parent=root))  
    root.destroy()
    return path 
开发者ID:Qirky,项目名称:PyKinectTk,代码行数:8,代码来源:__init__.py

示例8: asksaveasfilename

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askdirectory [as 别名]
def asksaveasfilename(self):
        if not self.parent.filename:
            self.parent.set_info_box(message='Error: No figure has been created yet.')
        else:
            file_options = {}
            file_options['initialdir'] = self.parent.par.run.out_dir
            file_options['initialfile'] = re.sub('/.+/', '', self.parent.filename)
            file_options['filetypes'] = [('pdf files', '.pdf')]
            file_options['parent'] = self.parent
            file_options['title'] = 'save figure as'
            filename = tkFileDialog.askdirectory(**file_options)
            if filename:
                copyfile(self.parent.filename, filename) 
开发者ID:VCCRI,项目名称:SVPV,代码行数:15,代码来源:gui_widgets.py

示例9: set_plot_all_dir

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askdirectory [as 别名]
def set_plot_all_dir(self):
        dir_options = {}
        dir_options['initialdir'] = self.par.run.out_dir
        dir_options['parent'] = self
        dir_options['title'] = 'select existing or type new directory'
        dir_options['mustexist'] = False
        path = tkFileDialog.askdirectory(**dir_options)
        if path == '':
            return None
        else:
            return path 
开发者ID:VCCRI,项目名称:SVPV,代码行数:13,代码来源:gui.py

示例10: browse

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askdirectory [as 别名]
def browse(self, entrywidget, options):
                path = filedialog.askdirectory()
                if os.path.isdir(path):
                        entrywidget.delete('0', 'end')
                        entrywidget.insert('end', path + os.sep + os.path.basename(options['lfile']['def'])) 
开发者ID:SystemRage,项目名称:py-kms,代码行数:7,代码来源:pykms_GuiBase.py

示例11: callback

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askdirectory [as 别名]
def callback(path):
    folder = tkFileDialog.askdirectory(initialdir='C:/', title='Extract files from pcap') 
    path.set(folder)

#exit gui 
开发者ID:Beercow,项目名称:ProcDOT-Plugins,代码行数:7,代码来源:pcap_tools.py

示例12: set_cwd

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askdirectory [as 别名]
def set_cwd(self):
        """Set current working directory."""
        p = filedialog.askdirectory(title="Set directory",
                                    initialdir=self.toolbox_root)
        self.check_path(p) 
开发者ID:NeuromorphicProcessorProject,项目名称:snn_toolbox,代码行数:7,代码来源:gui.py

示例13: set_dataset_path

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askdirectory [as 别名]
def set_dataset_path(self):
        """Set path to dataset."""
        p = filedialog.askdirectory(title="Set directory",
                                    initialdir=self.toolbox_root)
        self.check_dataset_path(p) 
开发者ID:NeuromorphicProcessorProject,项目名称:snn_toolbox,代码行数:7,代码来源:gui.py

示例14: diropenbox

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askdirectory [as 别名]
def diropenbox(msg=None
    , title=None
    , default=None
    ):
    """
    A dialog to get a directory name.
    Note that the msg argument, if specified, is ignored.

    Returns the name of a directory, or None if user chose to cancel.

    If the "default" argument specifies a directory name, and that
    directory exists, then the dialog box will start with that directory.
    """
    if sys.platform == 'darwin':
        _bring_to_front()
    title=getFileDialogTitle(msg,title)
    localRoot = Tk()
    localRoot.withdraw()
    if not default: default = None
    f = tk_FileDialog.askdirectory(
          parent=localRoot
        , title=title
        , initialdir=default
        , initialfile=None
        )
    localRoot.destroy()
    if not f: return None
    return os.path.normpath(f)



#-------------------------------------------------------------------
# getFileDialogTitle
#------------------------------------------------------------------- 
开发者ID:redcanari,项目名称:canari3,代码行数:36,代码来源:easygui.py

示例15: body

# 需要导入模块: import tkFileDialog [as 别名]
# 或者: from tkFileDialog import askdirectory [as 别名]
def body(self, master, row, columns=DEFAULT_COLUMNS, **kwargs):
        """
        Place the required elements using the grid layout method.

        Returns the number of rows taken by this element.
        """
        label = ttk.Label(master, text=self.text)
        label.grid(row=row, column=0, columnspan=1, sticky="e")
        self.entry = ttk.Entry(master, textvariable=self.value)
        self.entry.grid(row=row, column=1, columnspan=columns - 1, sticky="ew")
        if self.directory:
            self.choose = ttk.Button(
                master,
                text="Choose...",
                command=lambda: self.value.set(tkFileDialog.askdirectory()),
            )
        else:
            self.choose = ttk.Button(
                master,
                text="Choose...",
                command=lambda: self.value.set(tkFileDialog.askopenfilename()),
            )
        self.choose.grid(row=row + 1, column=1, sticky="w")
        if self.optional:
            self.clear = ttk.Button(
                master, text="Clear", command=lambda: self.value.set("")
            )
            self.clear.grid(row=row + 1, column=2, sticky="e")
        return 2 
开发者ID:FowlerLab,项目名称:Enrich2,代码行数:31,代码来源:dialog_elements.py


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