-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.py
200 lines (170 loc) · 7.32 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# ///////////////////////////////////////////////////////////////
# ///////////////////////////////////////////////////////////////
#
# BY: WANDERSON M.PIMENTA
# PROJECT MADE WITH: Qt Designer and PySide6
# V: 1.0.0
#
# This project can be used freely for all uses, as long as they maintain the
# respective credits only in the Python scripts, any information in the visual
# interface (GUI) can be modified without any implication.
#
# There are limitations on Qt licenses if you want to use your products
# commercially, I recommend reading them on the official website:
# https://doc.qt.io/qtforpython/licenses.html
#
# ///////////////////////////////////////////////////////////////
# IMPORT PACKAGES AND MODULES
# ///////////////////////////////////////////////////////////////
from gui.uis.windows.main_window.functions_main_window import *
import sys
import os
import time
# IMPORT QT CORE
# ///////////////////////////////////////////////////////////////
from gui.core.qt_core import *
# IMPORT SETTINGS
# ///////////////////////////////////////////////////////////////
from gui.core.json_settings import Settings
# IMPORT PY ONE DARK WINDOWS
# ///////////////////////////////////////////////////////////////
# MAIN WINDOW
from gui.uis.windows.main_window import *
# IMPORT PY ONE DARK WIDGETS
# ///////////////////////////////////////////////////////////////
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"'
# MAIN WINDOW
# ///////////////////////////////////////////////////////////////
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
# SETUP MAIN WINDOw
# 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
# Run function when btn is clicked
# Check funtion by object name / btn_id
# ///////////////////////////////////////////////////////////////
def btn_clicked(self):
# GET BT CLICKED
btn = SetupMainWindow.setup_btns(self)
print(btn.objectName())
# LEFT MENU
# ///////////////////////////////////////////////////////////////
# OPEN PAGE HOME
if btn.objectName() == 'btn_home':
self.ui.left_menu.select_only_one(btn.objectName())
if MainFunctions.left_column_is_visible(self):
MainFunctions.toggle_left_column(self)
MainFunctions.load_main_credit_bar(self)
# Load Page
MainFunctions.set_page(self, self.ui.load_pages.page_1)
# OPEN PAGE pics
if btn.objectName() == 'btn_page_pics':
self.ui.left_menu.select_only_one(btn.objectName())
try:
self.ui.load_pages.gridLayout_2.itemAt(0).widget().setParent(None)
self.ui.load_pages.gridLayout_2.removeWidget(self.ui.load_pages.gridLayout_2.itemAt(0).widget())
except AttributeError:
pass
if not MainFunctions.left_column_is_visible(self):
MainFunctions.toggle_left_column(self)
MainFunctions.set_page(self, self.ui.load_pages.page_3)
MainFunctions.load_persons(self)
MainFunctions.update_image_count(self,0)
# OPEN PAGE 2
if btn.objectName() == 'btn_page_search':
self.ui.left_menu.select_only_one(btn.objectName())
if MainFunctions.left_column_is_visible(self):
MainFunctions.toggle_left_column(self)
MainFunctions.set_page(self, self.ui.load_pages.page_4)
MainFunctions.load_search_result(self)
if btn.objectName() == 'btn_page_duplicate':
self.ui.left_menu.select_only_one(btn.objectName())
if MainFunctions.left_column_is_visible(self):
MainFunctions.toggle_left_column(self)
MainFunctions.set_page(self, self.ui.load_pages.page_5)
MainFunctions.load_duplicate_result(self)
# OPEN Settings
if btn.objectName() == 'btn_settings' or btn.objectName() == 'btn_close_left_column':
if not MainFunctions.left_column_is_visible(self):
MainFunctions.toggle_left_column(self)
self.ui.left_menu.select_only_one_tab(btn.objectName())
else:
self.ui.left_menu.deselect_all_tab()
MainFunctions.toggle_left_column(self)
self.ui.left_menu.select_only_one_tab(btn.objectName)
'''
'''
# 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_left_column(self)
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)
else:
pass
# 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()
def closeEvent(self, event):
print("Detected")
self.close()
print("Closed")
# 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_())