Untitled

 avatar
unknown
plain_text
a year ago
2.6 kB
8
Indexable
import tkinter as tk
from tkinter import filedialog

# Dictionary mapping state abbreviations to full names
state_dict = {
    "AL": "Alabama", "AK": "Alaska", "AZ": "Arizona", "AR": "Arkansas", "CA": "California",
    "CO": "Colorado", "CT": "Connecticut", "DE": "Delaware", "FL": "Florida", "GA": "Georgia",
    "HI": "Hawaii", "ID": "Idaho", "IL": "Illinois", "IN": "Indiana", "IA": "Iowa", "KS": "Kansas",
    "KY": "Kentucky", "LA": "Louisiana", "ME": "Maine", "MD": "Maryland", "MA": "Massachusetts",
    "MI": "Michigan", "MN": "Minnesota", "MS": "Mississippi", "MO": "Missouri", "MT": "Montana",
    "NE": "Nebraska", "NV": "Nevada", "NH": "New Hampshire", "NJ": "New Jersey", "NM": "New Mexico",
    "NY": "New York", "NC": "North Carolina", "ND": "North Dakota", "OH": "Ohio", "OK": "Oklahoma",
    "OR": "Oregon", "PA": "Pennsylvania", "RI": "Rhode Island", "SC": "South Carolina",
    "SD": "South Dakota", "TN": "Tennessee", "TX": "Texas", "UT": "Utah", "VT": "Vermont",
    "VA": "Virginia", "WA": "Washington", "WV": "West Virginia", "WI": "Wisconsin", "WY": "Wyoming"
}

def browse_file():
    file_path = filedialog.askopenfilename()
    file_entry.delete(0, tk.END)
    file_entry.insert(0, file_path)

def generate():
    selected_state = state_combo.get()
    input_directory = file_entry.get()
    output_directory = output_entry.get()
    # Add your code to generate based on selected state and directories

# Create the main window
root = tk.Tk()
root.title("Data Generator")

# Directory field with label and browse button
file_frame = tk.Frame(root)
file_frame.pack(pady=10)

file_label = tk.Label(file_frame, text="Input Directory:")
file_label.grid(row=0, column=0, padx=5)

file_entry = tk.Entry(file_frame, width=50)
file_entry.grid(row=0, column=1, padx=5)

browse_button = tk.Button(file_frame, text="Browse", command=browse_file)
browse_button.grid(row=0, column=2, padx=5)

# State combo box
state_label = tk.Label(root, text="Select State:")
state_label.pack()

state_abbrs = list(state_dict.keys())
state_combo = tk.StringVar()
state_combo.set(state_abbrs[0])
state_dropdown = tk.OptionMenu(root, state_combo, *state_abbrs)
state_dropdown.pack()

# Output directory
output_label = tk.Label(root, text="Output Directory:")
output_label.pack()

output_entry = tk.Entry(root, width=50)
output_entry.pack()

# Generate button
generate_button = tk.Button(root, text="Generate", command=generate)
generate_button.pack(pady=10)

# Run the main event loop
root.mainloop()
Editor is loading...
Leave a Comment