-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
175 lines (143 loc) · 6.14 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
from gui.uis.windows.main_window.functions_main_window import *
import sys
import os
from qt_core import *
from gui.core.json_settings import Settings
from gui.uis.windows.main_window import *
from gui.widgets import *
# ADJUST QT FONT DPI FOR HIGHT SCALE AN 4K MONITOR
os.environ["QT_FONT_DPI"] = "96"
# IF IS 4K MONITOR ENABLE 'os.environ["QT_SCALE_FACTOR"] = "2"'
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
# Load widgets from "gui\uis\main_window\ui_main.py"
self.ui = UI_MainWindow()
self.ui.setup_ui(self)
# LOAD SETTINGS
settings = Settings()
self.settings = settings.items
# SETUP MAIN WINDOW
self.hide_grips = True # Show/Hide resize grips
SetupMainWindow.setup_gui(self)
# SHOW MAIN WINDOW
self.show()
# LEFT MENU BTN IS CLICKED # Check funtion by object name / btn_id
def btn_clicked(self):
# GET BT CLICKED
btn = SetupMainWindow.setup_btns(self)
# Remove Selection If Clicked By "btn_close_left_column"
if btn.objectName() != "btn_settings":
self.ui.left_menu.deselect_all_tab()
# Get Title Bar Btn And Reset Active
top_settings = MainFunctions.get_title_bar_btn(self, "btn_top_settings")
top_settings.set_active(False)
# LEFT MENU
# HOME BTN
if btn.objectName() == "btn_home":
# Select Menu
self.ui.left_menu.select_only_one(btn.objectName())
# Load Page 1
MainFunctions.set_page(self, self.ui.load_pages.page_1)
# WIDGETS BTN
if btn.objectName() == "btn_widgets":
# Select Menu
self.ui.left_menu.select_only_one(btn.objectName())
# Load Page 2
MainFunctions.set_page(self, self.ui.load_pages.page_2)
# LOAD USER PAGE
if btn.objectName() == "btn_add_user":
# Select Menu
self.ui.left_menu.select_only_one(btn.objectName())
# Load Page 3
MainFunctions.set_page(self, self.ui.load_pages.page_3)
# BOTTOM INFORMATION
if btn.objectName() == "btn_info":
# CHECK IF LEFT COLUMN IS VISIBLE
if not MainFunctions.left_column_is_visible(self):
self.ui.left_menu.select_only_one_tab(btn.objectName())
# Show / Hide
MainFunctions.toggle_left_column(self)
self.ui.left_menu.select_only_one_tab(btn.objectName())
else:
if btn.objectName() == "btn_close_left_column":
self.ui.left_menu.deselect_all_tab()
# Show / Hide
MainFunctions.toggle_left_column(self)
self.ui.left_menu.select_only_one_tab(btn.objectName())
# Change Left Column Menu
if btn.objectName() != "btn_close_left_column":
MainFunctions.set_left_column_menu(
self,
menu = self.ui.left_column.menus.menu_2,
title = "Info tab",
icon_path = Functions.set_svg_icon("icon_info.svg")
)
# SETTINGS LEFT
if btn.objectName() == "btn_settings" or btn.objectName() == "btn_close_left_column":
# CHECK IF LEFT COLUMN IS VISIBLE
if not MainFunctions.left_column_is_visible(self):
# Show / Hide
MainFunctions.toggle_left_column(self)
self.ui.left_menu.select_only_one_tab(btn.objectName())
else:
if btn.objectName() == "btn_close_left_column":
self.ui.left_menu.deselect_all_tab()
# Show / Hide
MainFunctions.toggle_left_column(self)
self.ui.left_menu.select_only_one_tab(btn.objectName())
# Change Left Column Menu
if btn.objectName() != "btn_close_left_column":
MainFunctions.set_left_column_menu(
self,
menu = self.ui.left_column.menus.menu_1,
title = "Settings Left Column",
icon_path = Functions.set_svg_icon("icon_settings.svg")
)
# TITLE BAR MENU
# SETTINGS TITLE BAR
if btn.objectName() == "btn_top_settings":
# Toogle Active
if not MainFunctions.right_column_is_visible(self):
btn.set_active(True)
# Show / Hide
MainFunctions.toggle_right_column(self)
else:
btn.set_active(False)
# Show / Hide
MainFunctions.toggle_right_column(self)
# Get Left Menu Btn
top_settings = MainFunctions.get_left_menu_btn(self, "btn_settings")
top_settings.set_active_tab(False)
# DEBUG
print(f"Button {btn.objectName()}, clicked!")
# LEFT MENU BTN IS RELEASED
# Run function when btn is released
# Check funtion by object name / btn_id
# ///////////////////////////////////////////////////////////////
def btn_released(self):
# GET BT CLICKED
btn = SetupMainWindow.setup_btns(self)
# DEBUG
print(f"Button {btn.objectName()}, released!")
# RESIZE EVENT
# ///////////////////////////////////////////////////////////////
def resizeEvent(self, event):
SetupMainWindow.resize_grips(self)
# MOUSE CLICK EVENTS
# ///////////////////////////////////////////////////////////////
def mousePressEvent(self, event):
# SET DRAG POS WINDOW
self.dragPos = event.globalPos()
# SETTINGS WHEN TO START
# Set the initial class and also additional parameters of the "QApplication" class
# ///////////////////////////////////////////////////////////////
if __name__ == "__main__":
# APPLICATION
# ///////////////////////////////////////////////////////////////
app = QApplication(sys.argv)
app.setWindowIcon(QIcon("icon.ico"))
window = MainWindow()
# EXEC APP
# ///////////////////////////////////////////////////////////////
sys.exit(app.exec())