Update GUI.py

pull/1206/head
RapidStoned 3 years ago
parent b8cbffdcce
commit ca1faf997f

@ -1,4 +1,6 @@
from main import main, shutdown #from main import main, shutdown
from doctest import master
import tkinter import tkinter
import tkinter.messagebox import tkinter.messagebox
import customtkinter import customtkinter
@ -9,8 +11,8 @@ customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "gre
class App(customtkinter.CTk): class App(customtkinter.CTk):
WIDTH = 780 WIDTH = 1200
HEIGHT = 520 HEIGHT = 600
def __init__(self): def __init__(self):
super().__init__() super().__init__()
@ -31,8 +33,17 @@ class App(customtkinter.CTk):
corner_radius=0) corner_radius=0)
self.frame_left.grid(row=0, column=0, sticky="nswe") self.frame_left.grid(row=0, column=0, sticky="nswe")
self.frame_right = customtkinter.CTkFrame(master=self) # Results Frame
self.frame_right.grid(row=0, column=1, sticky="nswe", padx=20, pady=20) self.frame_results = customtkinter.CTkFrame(master=self)
self.frame_results.grid(row=0, column=1, sticky="nswe", padx=20, pady=20)
# Settings Frame
self.frame_settings = customtkinter.CTkFrame(master=self)
self.frame_settings.grid(row=0, column=1, sticky="nswe", padx=20, pady=20)
# Home Frame
self.frame_home = customtkinter.CTkFrame(master=self)
self.frame_home.grid(row=0, column=1, sticky="nswe", padx=20, pady=20)
# ============ frame_left ============ # ============ frame_left ============
@ -47,38 +58,161 @@ class App(customtkinter.CTk):
text_font=("Roboto Medium", -16)) # font name and size in px text_font=("Roboto Medium", -16)) # font name and size in px
self.label_1.grid(row=1, column=0, pady=10, padx=10) self.label_1.grid(row=1, column=0, pady=10, padx=10)
self.button_1 = customtkinter.CTkButton(master=self.frame_left, # Home Btn
self.home_btn = customtkinter.CTkButton(master=self.frame_left,
text="Home", text="Home",
command=self.button_event) command=self.btn_home)
self.button_1.grid(row=2, column=0, pady=10, padx=20) self.home_btn.grid(row=2, column=0, pady=10, padx=20)
self.button_2 = customtkinter.CTkButton(master=self.frame_left, # Settings Btn
self.settings_btn = customtkinter.CTkButton(master=self.frame_left,
text="Settings", text="Settings",
command=self.button_event) command=self.btn_settings)
self.button_2.grid(row=3, column=0, pady=10, padx=20) self.settings_btn.grid(row=3, column=0, pady=10, padx=20)
self.button_3 = customtkinter.CTkButton(master=self.frame_left, # Results Btn
self.results_btn = customtkinter.CTkButton(master=self.frame_left,
text="Results", text="Results",
command=self.button_event) command=self.btn_results)
self.button_3.grid(row=4, column=0, pady=10, padx=20) self.results_btn.grid(row=4, column=0, pady=10, padx=20)
# Start Btn
self.start_btn = customtkinter.CTkButton(master=self.frame_left,
text="Start",
command=self.btn_start)
self.start_btn.grid(row=5, column=0, pady=10, padx=40)
# Appeareance Stuff
self.label_mode = customtkinter.CTkLabel(master=self.frame_left, text="Appearance Mode:") self.label_mode = customtkinter.CTkLabel(master=self.frame_left, text="Appearance Mode:")
self.label_mode.grid(row=9, column=0, pady=0, padx=20, sticky="w") self.label_mode.grid(row=9, column=0, pady=10, padx=20, sticky="w")
self.optionmenu_1 = customtkinter.CTkOptionMenu(master=self.frame_left, self.optionmenu_1 = customtkinter.CTkOptionMenu(master=self.frame_left,
values=["Light", "Dark", "System"], values=["Light", "Dark", "System"],
command=self.change_appearance_mode) command=self.change_appearance_mode)
self.optionmenu_1.grid(row=10, column=0, pady=10, padx=20, sticky="w") self.optionmenu_1.grid(row=10, column=0, pady=0, padx=20, sticky="w")
# frame_home
self.frame_config(self.frame_home)
# frame_settings
self.frame_settings.rowconfigure(0)
self.frame_settings.columnconfigure(0)
# frame_results
self.frame_config(self.frame_results)
### Adds all the stuff for frame_settings ###
# Background within frame
self.frame_bg_settings = customtkinter.CTkFrame(master=self.frame_settings)
self.frame_bg_settings.grid(row=0, column=0, pady=15, padx=15, sticky=("nswe"))
self.frame_bg_settings.rowconfigure(10, weight=1)
self.frame_bg_settings.columnconfigure(10, weight=1)
# Title
self.settings_title = customtkinter.CTkLabel(
master=self.frame_bg_settings,
text="Settings",
text_font=("Courier_Bold", 24)
)
self.settings_title.grid(row=0, column=0, columnspan=8, pady=15, padx=15)
## USER SETTINGS ##
# User settings title
self.user_title = customtkinter.CTkLabel(
master=self.frame_bg_settings,
text="User Settings",
text_font=("Courier_Bold", 14)
)
self.user_title.grid(row=1, column=0, columnspan=2)
# Client secret input box
self.client_secret = customtkinter.CTkEntry(
master=self.frame_bg_settings,
placeholder_text = "Client Secret"
)
self.client_secret.grid(row=2, column=0, pady=5, padx=15)
# Client id input box
self.client_id = customtkinter.CTkEntry(
master=self.frame_bg_settings,
placeholder_text = "Client Id"
)
self.client_id.grid(row=3, column=0, pady=5, padx=15)
# Username
self.user_name = customtkinter.CTkEntry(
master=self.frame_bg_settings,
placeholder_text = "Username"
)
self.user_name.grid(row=2, column=1, pady=5, padx=15)
# Password
self.user_password = customtkinter.CTkEntry(
master=self.frame_bg_settings,
placeholder_text = "Password"
)
self.user_password.grid(row=3, column=1, pady=5, padx=15)
# 2fa label
self.user_2fa_label = customtkinter.CTkLabel(
master=self.frame_bg_settings,
text = "2FA enabled?"
)
self.user_2fa_label.grid(row=4, column=0, pady=0, padx=15)
# 2fa option menu
self.user_2fa = customtkinter.CTkOptionMenu(
master=self.frame_bg_settings,
values=["True", "False"]
)
self.user_2fa.grid(row=5, column=0, pady=0, padx=15)
## THREAD SETTINGS
# Thread Settings Title
self.thread_title = customtkinter.CTkLabel(
master=self.frame_bg_settings,
text="Thread Settings",
text_font=("Courier_Bold", 14)
)
self.thread_title.grid(row=1, column=3, columnspan=2)
# Subreddit
self.thread_subreddit = customtkinter.CTkEntry(
master=self.frame_bg_settings,
placeholder_text="Subreddit"
)
self.thread_subreddit.grid(row=2, column=3, pady=15, padx=15)
# Max Comment Lenght
self.thread_max_comment_lenght = customtkinter.CTkEntry(
master=self.frame_bg_settings,
placeholder_text="Max Comment Lenght"
)
self.thread_max_comment_lenght.grid(row=2, column=4, pady=15, padx=15)
# Post Id
self.thread_post_id = customtkinter.CTkEntry(
master=self.frame_bg_settings,
placeholder_text="Post Id"
)
self.thread_post_id.grid(row=3, column=3, pady=15, padx=15)
# Min Comment Lenght
self.thread_min_comment_lenght = customtkinter.CTkEntry(
master=self.frame_bg_settings,
placeholder_text="Min Comment Lenght"
)
self.thread_min_comment_lenght.grid(row=3, column=4, pady=15, padx=15)
# ============ frame_right ============
# configure grid layout (3x7) # configure grid layout (3x7)
self.frame_right.rowconfigure((0, 1, 2, 3), weight=1)
self.frame_right.rowconfigure(7, weight=10)
self.frame_right.columnconfigure((0, 1), weight=1)
self.frame_right.columnconfigure(2, weight=0)
self.frame_info = customtkinter.CTkFrame(master=self.frame_right) self.frame_info = customtkinter.CTkFrame(master=self.frame_home)
self.frame_info.grid(row=0, column=0, columnspan=2, rowspan=4, pady=20, padx=20, sticky="nsew") self.frame_info.grid(row=0, column=0, columnspan=2, rowspan=4, pady=20, padx=20, sticky="nsew")
# ============ frame_info ============ # ============ frame_info ============
@ -88,10 +222,10 @@ class App(customtkinter.CTk):
self.frame_info.columnconfigure(0, weight=1) self.frame_info.columnconfigure(0, weight=1)
self.label_info_1 = customtkinter.CTkLabel(master=self.frame_info, self.label_info_1 = customtkinter.CTkLabel(master=self.frame_info,
text=" Thanks for using this tool! \n" + text="Thanks for using this tool! \n" +
"Feel free to contribute to this project on GitHub!\n"+ "Feel free to contribute to this project on GitHub!\n"+
"If you have any questions, feel free to reach out to me on Twitter or submit a GitHub issue. \n"+ "If you have any questions, feel free to reach out to\nme on Twitter or submit a GitHub issue. \n"+
"You can find solutions to many common problems in the Documentation: https://reddit-video-maker-bot.netlify.app/" , "You can find solutions to many common problems in the Documentation\nhttps://reddit-video-maker-bot.netlify.app/" ,
height=100, height=100,
corner_radius=6, # <- custom corner radius corner_radius=6, # <- custom corner radius
fg_color=("white", "gray38"), # <- custom tuple-color fg_color=("white", "gray38"), # <- custom tuple-color
@ -115,16 +249,43 @@ class App(customtkinter.CTk):
###self.check_box_1.configure(state=tkinter.DISABLED, text="CheckBox disabled") ###self.check_box_1.configure(state=tkinter.DISABLED, text="CheckBox disabled")
###self.check_box_2.select() ###self.check_box_2.select()
def button_event(self): # Configures the frames of the right side
print("Button pressed") def frame_config(self, frame):
frame.rowconfigure(8, weight=1)
frame.columnconfigure(8, weight=10)
# Show frame
def showFrame(self, frame):
frame.tkraise()
# Home button event
def btn_home(self):
self.showFrame(self.frame_home)
# Settings button event
def btn_settings(self):
self.showFrame(self.frame_settings)
# Results button event
def btn_results(self):
print("Results Pressed!")
# Start button event
def btn_start(self):
print("Start Pressed!")
# Appearance event
def change_appearance_mode(self, new_appearance_mode): def change_appearance_mode(self, new_appearance_mode):
customtkinter.set_appearance_mode(new_appearance_mode) customtkinter.set_appearance_mode(new_appearance_mode)
# Close event
def on_closing(self, event=0): def on_closing(self, event=0):
self.destroy()
shutdown() shutdown()
def start():
if __name__ == "__main__": if __name__ == "__main__":
app = App() app = App()
app.mainloop() app.mainloop()
start()
Loading…
Cancel
Save