當前位置: 首頁>>代碼示例>>Python>>正文


Python filedialog.askdirectory方法代碼示例

本文整理匯總了Python中tkinter.filedialog.askdirectory方法的典型用法代碼示例。如果您正苦於以下問題:Python filedialog.askdirectory方法的具體用法?Python filedialog.askdirectory怎麽用?Python filedialog.askdirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tkinter.filedialog的用法示例。


在下文中一共展示了filedialog.askdirectory方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: choose_folder

# 需要導入模塊: from tkinter import filedialog [as 別名]
# 或者: from tkinter.filedialog import askdirectory [as 別名]
def choose_folder(project_name):
    global current_video, projectini
    projectini = project_name
    img_dir = filedialog.askdirectory()
    os.chdir(img_dir)
    dirpath = os.path.basename(os.getcwd())
    current_video = dirpath
    print('Current Video: ' + current_video)

    global frames_in
    frames_in = []
    for i in os.listdir(os.curdir):
        if i.__contains__(".png"):
            frames_in.append(i)
        reset()

    frames_in = sorted(frames_in, key=lambda x: int(x.split('.')[0]))
    # print(frames_in)
    number_of_frames = len(frames_in)
    print("Number of Frames: " + str(number_of_frames))

    configure(project_name)

    MainInterface()
    #create_data_frame(number_of_frames) 
開發者ID:sgoldenlab,項目名稱:simba,代碼行數:27,代碼來源:labelling_aggression.py

示例2: choose_directory

# 需要導入模塊: from tkinter import filedialog [as 別名]
# 或者: from tkinter.filedialog import askdirectory [as 別名]
def choose_directory():
    directory_root = Tk()
    directory_root.withdraw()
    path_work = filedialog.askdirectory()
    if path_work == '':
        print('你沒有選擇目錄! 請重新選:')
        sleep(2)
        return choose_directory()
    else:
        # askdirectory 獲得是 正斜杠 路徑C:/,所以下麵要把 / 換成 反斜杠\
        return path_work.replace('/', sep)


# 功能:檢查 歸類根目錄 的合法性
# 參數:用戶自定義的歸類根目錄,用戶選擇整理的文件夾路徑
# 返回:歸類根目錄路徑
# 輔助:os.sep,os.system 
開發者ID:junerain123,項目名稱:javsdt,代碼行數:19,代碼來源:functions_preparation.py

示例3: select_destination

# 需要導入模塊: from tkinter import filedialog [as 別名]
# 或者: from tkinter.filedialog import askdirectory [as 別名]
def select_destination(self):
        """
        Check if the destination path is in the command line arguments,
        if not ask user for input using filedialog.
        If the destination path in arguments does not exist create it.
        :return: str. Destination folder path.
        """
        if self.args.dstcwd:
            destination = os.getcwd()
        else:
            if self.args.dest is None:
                print("Choose a destination path.")
                destination = os.path.normpath(askdirectory())
                print(f"Destination path: {destination}")
            else:
                destination = self.args.dest
                if not os.path.exists(destination):
                    os.makedirs(destination)
        return destination 
開發者ID:pltnk,項目名稱:selective_copy,代碼行數:21,代碼來源:process.py

示例4: browse_directory

# 需要導入模塊: from tkinter import filedialog [as 別名]
# 或者: from tkinter.filedialog 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

示例5: select_folder

# 需要導入模塊: from tkinter import filedialog [as 別名]
# 或者: from tkinter.filedialog import askdirectory [as 別名]
def select_folder(title="Select folder", folder=".", master=None):
    """
    Display a box to select a folder.

    If a folder is selected the folder path is returned, otherwise `None` is returned.

    :param string title:
        The title to be displayed on the box. Defaults to 'Select file'.
    :param string folder:
        The initial folder to open. Defaults to '.'.
    :param App master:
        Optional guizero master which the popup will be placed over. Defaults
        to `None`.
    :return:
        The path of folder selected or `None`.
    """
    if not os.path.isdir(folder):
        utils.error_format("The folder '{}' specified for select_folder does not exist.".format(folder))
        folder = "."
    
    return filedialog.askdirectory(title=title, initialdir=folder, parent=None if master is None else master.tk) 
開發者ID:lawsie,項目名稱:guizero,代碼行數:23,代碼來源:dialog.py

示例6: select_source

# 需要導入模塊: from tkinter import filedialog [as 別名]
# 或者: from tkinter.filedialog import askdirectory [as 別名]
def select_source(self):
        """
        Check if the source path is in the command line arguments,
        if not ask user for input using filedialog.
        :return: str. Source folder path.
        """
        if self.args.srccwd:
            source = os.getcwd()
        else:
            if self.args.source is None:
                print("Choose a source path.")
                source = os.path.normpath(askdirectory())
                print(f"Source path: {source}")
            else:
                source = self.args.source
        return source 
開發者ID:pltnk,項目名稱:selective_copy,代碼行數:18,代碼來源:process.py

示例7: openfile

# 需要導入模塊: from tkinter import filedialog [as 別名]
# 或者: from tkinter.filedialog import askdirectory [as 別名]
def openfile(self, event):
        if event.widget["text"] == "..":
            intput_type = self.input_type.get()
            if not intput_type:
                messagebox.showerror("Error", "please select the input type first.")
                return
            if intput_type == "video":
                self.input_filename = askopenfilenames(title='select', filetypes=[
                    ("all video format", ".mp4"),
                    ("all video format", ".flv"),
                    ("all video format", ".avi"),
                ])
            elif intput_type == "image":
                self.input_filename = askopenfilenames(title='select', filetypes=[
                    ("image", ".jpeg"),
                    ("image", ".png"),
                    ("image", ".jpg"),
                ])
            self.label0_["text"] = self.input_filename
        elif event.widget["text"] == "...":
            self.output_dir = askdirectory(title="select")
            self.label1_["text"] = self.output_dir 
開發者ID:MashiMaroLjc,項目名稱:rabbitVE,代碼行數:24,代碼來源:extract_face_view.py

示例8: browse_button

# 需要導入模塊: from tkinter import filedialog [as 別名]
# 或者: from tkinter.filedialog import askdirectory [as 別名]
def browse_button():
    # Allow user to select a directory and store it in global var
    # called folder_path
    global folder_path
    filename = filedialog.askdirectory()
    folder_path.set(filename)
    print(filename) 
開發者ID:rpotter12,項目名稱:spotify-downloader-music-player,代碼行數:9,代碼來源:test.py

示例9: choose_file

# 需要導入模塊: from tkinter import filedialog [as 別名]
# 或者: from tkinter.filedialog import askdirectory [as 別名]
def choose_file(self):
        path = filedialog.askdirectory(
            title="選擇下載文件夾",
        )
        if not path:
            return
        path = Path(path)
        self.label_text.set(str(path))
        if self._config is not None:
            self._config.op_store_path(self._store_name, path) 
開發者ID:winkidney,項目名稱:PickTrue,代碼行數:12,代碼來源:toolkit.py

示例10: choose_location

# 需要導入模塊: from tkinter import filedialog [as 別名]
# 或者: from tkinter.filedialog import askdirectory [as 別名]
def choose_location(self):
        """
        Shows a popup window to select a directory to choose save the lists generated. then sends the path to
        the main view.

        :author: Pablo Sanz Algucil
        """

        path = filedialog.askdirectory(title="Choose directory",
                                       initialdir="/home",
                                       mustexist=True)
        self.files_location = path
        self.main_view.get_notify_childs(4, self.files_location) 
開發者ID:pabloibiza,項目名稱:WiCC,代碼行數:15,代碼來源:wicc_view_wordlist.py

示例11: __select_excel_output

# 需要導入模塊: from tkinter import filedialog [as 別名]
# 或者: from tkinter.filedialog import askdirectory [as 別名]
def __select_excel_output(self, entry_box):
        path = askdirectory()
        entry_box.delete(0, len(entry_box.get()))
        entry_box.insert(0, path)
        return path 
開發者ID:liucaide,項目名稱:Andromeda,代碼行數:7,代碼來源:ui_input.py

示例12: select_dir

# 需要導入模塊: from tkinter import filedialog [as 別名]
# 或者: from tkinter.filedialog import askdirectory [as 別名]
def select_dir():
    global DIRS
    DIRS = filedialog.askdirectory()  # 獲得文件夾地址 
開發者ID:jtyoui,項目名稱:Jtyoui,代碼行數:5,代碼來源:tk.py

示例13: load_folder

# 需要導入模塊: from tkinter import filedialog [as 別名]
# 或者: from tkinter.filedialog import askdirectory [as 別名]
def load_folder(project_name):
    global current_video
    img_dir = filedialog.askdirectory()
    os.chdir(img_dir)
    print("Working directory is %s" % os.getcwd())
    dirpath = os.path.basename(os.getcwd())
    current_video = dirpath
    print('Current Video: ' + current_video)
    ## get the frames
    global frames_in
    frames_in = []
    for i in os.listdir(os.curdir):
        if i.__contains__(".png"):
            frames_in.append(i)
        reset()

    frames_in = sorted(frames_in, key=lambda x: int(x.split('.')[0]))
    # print(frames_in)
    number_of_frames = len(frames_in)
    print("Number of Frames: " + str(number_of_frames))

    configure(project_name)
    curr_target_csv= os.path.join(os.path.dirname(project_name),'csv','targets_inserted',os.path.basename(img_dir)+'.csv')
    df = pd.read_csv(curr_target_csv)
    df = df.fillna(0)
    print(df)
    MainInterface()
    #create_data_frame(number_of_frames) 
開發者ID:sgoldenlab,項目名稱:simba,代碼行數:30,代碼來源:load_labelling_aggression_hxt.py

示例14: dec_path

# 需要導入模塊: from tkinter import filedialog [as 別名]
# 或者: from tkinter.filedialog import askdirectory [as 別名]
def dec_path():
    path = askdirectory(title = 'Select directory with files to decrypt')
    if path == None or path == '':
        messagebox.showwarning('Error', 'No path selected, exiting...')
        return False
    path =  path + '/'
    return path 
開發者ID:leonv024,項目名稱:RAASNet,代碼行數:9,代碼來源:decrypt.py

示例15: __init__

# 需要導入模塊: from tkinter import filedialog [as 別名]
# 或者: from tkinter.filedialog import askdirectory [as 別名]
def __init__(self, initialdir, file_type):
        if file_type == 'dir':
            self.choice = filedialog.askdirectory(initialdir=initialdir) 
開發者ID:TristenHarr,項目名稱:MyPyBuilder,代碼行數:5,代碼來源:FileDialogClass.py


注:本文中的tkinter.filedialog.askdirectory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。