Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
3.3 kB
4
Indexable
Never
import tkinter as tk
from tkinter import filedialog
import os

# 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()
    selected_script = script_combo.get()
    input_directory = file_entry.get()
    output_directory = output_entry.get()
    # Add your code to generate based on selected state, selected script, and directories
    if selected_script:
        # Assuming selected_script is the file name
        script_path = os.path.join(os.getcwd(), "scripts", selected_script)  # Modify this path accordingly
        os.system(f"python {script_path} {selected_state} {input_directory} {output_directory}")

# 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()

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

# Assuming you have Python scripts in a directory named 'scripts'
script_files = [f for f in os.listdir("scripts") if f.endswith(".py")]
script_combo = tk.StringVar()
script_dropdown = tk.OptionMenu(root, script_combo, *script_files)
script_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()
Leave a Comment