# Select directory path with gradio or tkinter

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fselect-directory-path-with-gradio-or-tkinter%2F53324%3E%5C
**Category:** 🔒 Gradio\
**Created:** [September 3, 2023, 7:53am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fselect-directory-path-with-gradio-or-tkinter%2F53324 "2023-09-03T07:53:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RazaGR](https://avatars.discourse-cdn.com/v4/letter/r/7ab992/32.png) [@RazaGR](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FRazaGR)%5C
**Post date:** [September 3, 2023, 7:53am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fselect-directory-path-with-gradio-or-tkinter%2F53324%2F1 "2023-09-03T07:53:13Z")

</div>

is it possible to select a directory path with gradio? I want to have a button when clicked I should be able to select directory, I tried with `tkinter` but that gives me error:

```auto
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!

```

code

```auto
import gradio as gr
import tkinter as tk
from tkinter import filedialog

def select_directory(selected_folder):
    root = tk.Tk()
    root.withdraw()
    folder_path = filedialog.askdirectory()
    selected_folder.set_value(f"Selected Directory: {folder_path}")

with gr.Blocks(analytics_enabled=False) as ui_component:
    with gr.Row():
        selected_folder = gr.Textbox("", label="Selected Folder", lines=2)
        input_files = gr.Button("Select Directory")
        input_files.click(select_directory, selected_folder)

ui_component.launch()

```
