Merged frondend backend split with custom tkinter

This commit is contained in:
Samuel Walker 2024-06-20 08:34:28 -06:00
commit 786143081b

19
Main.py
View File

@ -3,6 +3,8 @@ import tkinter as tk
from tkinter import filedialog from tkinter import filedialog
import configparser import configparser
import Backend import Backend
import customtkinter
from customtkinter import *
# Initialize a configparser object for managing the configuration file # Initialize a configparser object for managing the configuration file
config = configparser.ConfigParser() config = configparser.ConfigParser()
@ -47,15 +49,16 @@ def main():
stored_prism_instance_path = default_prism_instance_path stored_prism_instance_path = default_prism_instance_path
# GUI for selecting Prism instance path # GUI for selecting Prism instance path
root = tk.Tk() app = CTk()
root.title("Select Prism Instance Path") set_appearance_mode("dark")
#root.title("Select Prism Instance Path")
# Label for instructions # Label for instructions
label = tk.Label(root, text="Select Prism instance path:") label = CTkLabel(master=app, text="Select Prism instance path:")
label.pack(pady=10) label.pack(pady=10)
# Entry widget for Prism instance path # Entry widget for Prism instance path
prism_instance_path_entry = tk.Entry(root, width=50) prism_instance_path_entry = CTkEntry(master=app, width=50)
prism_instance_path_entry.pack(pady=5) prism_instance_path_entry.pack(pady=5)
# If a stored Prism instance path exists, pre-fill the entry widget # If a stored Prism instance path exists, pre-fill the entry widget
@ -63,20 +66,20 @@ def main():
prism_instance_path_entry.insert(0, stored_prism_instance_path) prism_instance_path_entry.insert(0, stored_prism_instance_path)
# Button to select directory # Button to select directory
select_button = tk.Button(root, text="Browse...", command=select_prism_instance_path) select_button = CTkButton(master=app, text="Browse...", command=select_prism_instance_path)
select_button.pack(pady=5) select_button.pack(pady=5)
# Function to proceed with installation # Function to proceed with installation
def start_installation(): def start_installation():
prism_instance_path = prism_instance_path_entry.get() prism_instance_path = prism_instance_path_entry.get()
root.destroy() # Close the GUI window app.destroy() # Close the GUI window
Backend.perform_installation(instance_name, prism_command, prism_instance_path) Backend.perform_installation(instance_name, prism_command, prism_instance_path)
# Button to start installation # Button to start installation
install_button = tk.Button(root, text="Launch Minecraft", command=start_installation) install_button = CTkButton(master=app, text="Launch Minecraft", command=start_installation)
install_button.pack(pady=10) install_button.pack(pady=10)
root.mainloop() app.mainloop()
if __name__ == "__main__": if __name__ == "__main__":
main() main()