-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
88 lines (73 loc) · 2.95 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from threading import Thread
import tkinter as tk
from tkinter import filedialog
from tkinter import font as tkfont
from tkinter import ttk
from scripts.main import Project
# setup
root = tk.Tk()
root.title("Framework Automater")
# variables
FRAMEWORK_OPTIONS = ["Django", "React", "GO", "Express"]
folder_path = tk.StringVar()
selected_framework = tk.StringVar()
project_name = tk.StringVar()
error = tk.StringVar()
status = tk.StringVar()
status.set("Create Project")
# functions
def execute_command(framework, path, name):
project = Project(path=path, name=name)
if framework == "Django":
project.django()
elif framework == "React":
project.react()
elif framework == "GO":
project.go()
elif framework == "Express":
project.express()
def browse_folder():
folder_selected = filedialog.askdirectory()
if folder_selected:
folder_path.set(folder_selected)
def validate(selected_framework, folder_path, project_name):
selected_framework, folder_path, project_name = selected_framework.get(), folder_path.get(), project_name.get()
if selected_framework and folder_path and project_name:
error.set("")
status.set("Creating project...")
execute_command(selected_framework, folder_path, project_name)
else:
error.set("Please select a framework, a name and a folder path!")
# Error message
error_label = tk.Label(root, textvariable=error, fg="red")
error_label.pack()
# Title
heading_font = tkfont.Font(family="Helvetica", size=24, weight="bold")
heading_label = tk.Label(root, text="Framework Automater", font=heading_font)
heading_label.pack(pady=(20, 10))
# dropdown menu
dropdown_frame = tk.Frame(root)
dropdown_frame.pack(pady=(10, 20), padx=20, fill=tk.X)
dropdown_label = tk.Label(dropdown_frame, text="Select an option:")
dropdown_label.pack(side=tk.LEFT)
dropdown_menu = ttk.Combobox(dropdown_frame, textvariable=selected_framework , state="readonly")
dropdown_menu['values'] = FRAMEWORK_OPTIONS
dropdown_menu.pack(side=tk.LEFT, padx=(10, 0), fill=tk.X, expand=True)
# project name
project_frame = tk.Frame(root)
project_frame.pack(pady=(10, 20), padx=20, fill=tk.X)
project_name_label = tk.Label(project_frame, text="Enter project name:")
project_name_label.pack(side=tk.LEFT)
project_name_entry = tk.Entry(project_frame, textvariable=project_name)
project_name_entry.pack(side=tk.LEFT, padx=(10, 0), fill=tk.X, expand=True)
# folder selection
frame = tk.Frame(root)
frame.pack(pady=(10, 20), padx=20, fill=tk.X)
browse_button = tk.Button(frame, text="Select Folder Path", command=browse_folder)
browse_button.pack(side=tk.LEFT)
folder_entry = tk.Entry(frame, textvariable=folder_path, state='readonly', width=50)
folder_entry.pack(side=tk.LEFT, padx=(10, 0), fill=tk.X, expand=True)
# run button
run_button = tk.Button(root, textvariable=status, command=Thread(target=validate, args=(selected_framework, folder_path, project_name)).start)
run_button.pack(pady=(10, 20))
root.mainloop()