-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
125 lines (99 loc) · 5.63 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import customtkinter
import os
import bhubfuncs
bhf = bhubfuncs.BhubFunctionality()
# TODO edge and firefox are not respecting the window size feature, troubleshoot
customtkinter.set_appearance_mode("dark")
customtkinter.set_default_color_theme("dark-blue")
# TKinter arguments
PRIMARY = "#2e3034"
ACCENT = "#4f535a"
HOVER_COLOR = "#1e2c40"
root = customtkinter.CTk()
root.title("BrowserHub")
root.iconbitmap("Internet-Explorer.ico")
if os.name == "nt": # Windows OS window size
root.geometry("400x350")
elif os.name == "posix": # macOS window size
root.geometry("400x400")
check_chrome = customtkinter.BooleanVar()
check_firefox = customtkinter.BooleanVar()
check_edge = customtkinter.BooleanVar()
check_safari = customtkinter.BooleanVar()
select_all_var = customtkinter.BooleanVar()
chrome_menu_var = customtkinter.StringVar()
chrome_menu_var.set(list(bhf.size_menu.keys())[0])
firefox_menu_var = customtkinter.StringVar()
firefox_menu_var.set(list(bhf.size_menu.keys())[0])
edge_menu_var = customtkinter.StringVar()
edge_menu_var.set(list(bhf.size_menu.keys())[0])
safari_menu_var = customtkinter.StringVar()
safari_menu_var.set(list(bhf.size_menu.keys())[0])
checkbox_variables = [check_chrome, check_firefox, check_edge]
def select_all(checkboxes):
"""Toggles all checkboxes on or off"""
for checkbox in checkboxes:
for checkvar in checkbox_variables:
if not checkvar.get():
checkbox.toggle()
else:
checkbox.toggle()
# TODO if a box is already checked it should be left on when switch is activated
# TODO when switch is deactivated it should uncheck all boxes
# TODO if box is already unchecked then it should stay off when switch is deactivated
frame = customtkinter.CTkFrame(master=root)
frame.grid(pady=20, padx=60, rowspan=1, columnspan=1)
label = customtkinter.CTkLabel(master=frame, text="Select Browsers", font=("Sans Serif", 24))
label.grid(pady=12, padx=10, row=0, column=0, columnspan=2, sticky="nsew")
# Chrome's checkbox
chromebox = customtkinter.CTkCheckBox(master=frame, text="Chrome", command=bhf.append_chrome, variable=check_chrome)
chromebox.configure(command=lambda: bhf.append_chrome(check_chrome.get(), bhf.size_menu[chrome_menu_var.get()]))
chromebox.grid(pady=12, padx=10, row=2, column=0)
# Chrome's drop down menu
chromedrop = customtkinter.CTkOptionMenu(master=frame, values=list(bhf.size_menu.keys()), fg_color=PRIMARY,
button_color=ACCENT, dropdown_fg_color=PRIMARY,
dropdown_hover_color=HOVER_COLOR, variable=chrome_menu_var,
command=lambda value: bhf.update_window_size(value))
chromedrop.grid(pady=12, padx=10, row=2, column=1)
# Firefox's checkbox
foxbox = customtkinter.CTkCheckBox(master=frame, text="Firefox", command=bhf.append_firefox, variable=check_firefox)
foxbox.configure(command=lambda: bhf.append_firefox(check_firefox.get(), bhf.size_menu[firefox_menu_var.get()]))
foxbox.grid(pady=12, padx=10)
# Firefox's drop down menu
foxdrop = customtkinter.CTkOptionMenu(master=frame, values=list(bhf.size_menu.keys()), fg_color=PRIMARY,
button_color=ACCENT, dropdown_fg_color=PRIMARY,
dropdown_hover_color=HOVER_COLOR, variable=firefox_menu_var,
command=lambda value: bhf.update_window_size(value))
foxdrop.grid(pady=12, padx=10, row=3, column=1)
# Edge's checkbox
edgebox = customtkinter.CTkCheckBox(master=frame, text="Edge", command=bhf.append_edge, variable=check_edge)
edgebox.configure(command=lambda: bhf.append_edge(check_edge.get(), bhf.size_menu[edge_menu_var.get()]))
edgebox.grid(pady=12, padx=10)
# Edge's drop down menu
edgedrop = customtkinter.CTkOptionMenu(master=frame, values=list(bhf.size_menu.keys()), fg_color=PRIMARY,
button_color=ACCENT, dropdown_fg_color=PRIMARY,
dropdown_hover_color=HOVER_COLOR, variable=edge_menu_var,
command=lambda value: bhf.update_window_size(value))
edgedrop.grid(pady=12, padx=10, row=4, column=1)
# Safari's checkbox
if os.name == "posix": # Only adds safari checkbox to macOS
safaribox = customtkinter.CTkCheckBox(master=frame, text="Safari", command=bhf.append_safari,
variable=check_safari)
safaribox.configure(command=lambda: bhf.append_safari(check_safari.get(), bhf.size_menu[safari_menu_var.get()]))
safaribox.grid(pady=12, padx=10)
# Safari's drop down menu
safaridrop = customtkinter.CTkOptionMenu(master=frame, values=list(bhf.size_menu.keys()), fg_color=PRIMARY,
button_color=ACCENT, dropdown_fg_color=PRIMARY,
dropdown_hover_color=HOVER_COLOR, variable=safari_menu_var)
safaridrop.grid(pady=12, padx=10, row=7, column=1)
# Checkbox List
all_checkboxes = [chromebox, foxbox, edgebox] # Add safaribox
select_all_switch = customtkinter.CTkSwitch(master=frame, switch_width=40, switch_height=20, border_width=2,
corner_radius=10, progress_color="green", text="Select All",
command=select_all, variable=select_all_var)
select_all_switch.configure(command=lambda: select_all(all_checkboxes))
select_all_switch.grid(pady=12, padx=10)
# Launch button launches all browsers that have been selected via checkbox
button = customtkinter.CTkButton(master=frame, text="Launch", command=bhf.launch)
button.grid(pady=12, padx=10, columnspan=2, sticky="nsew")
root.mainloop()