-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
111 lines (90 loc) · 3.56 KB
/
main.py
File metadata and controls
111 lines (90 loc) · 3.56 KB
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
# ///////////////////////////////////////////////////////////////
#
# 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 sys
import os
from PyQt5 import QtWidgets,QtGui
from ui_functions import *
from usuarios import clearSession, getUsuarioLogueado
# IMPORT / GUI AND MODULES AND WIDGETS
# ///////////////////////////////////////////////////////////////
# FIX Problem for High DPI and Scale above 100%
os.environ["QT_FONT_DPI"] = "96"
# SET AS GLOBAL WIDGETS
# ///////////////////////////////////////////////////////////////
widgets = None
class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
self.return_to_login = False
self.setMinimumHeight(800)
self.setMinimumWidth(1200)
# SET AS GLOBAL WIDGETS
# ///////////////////////////////////////////////////////////////
from ui.ui_dashboard import Ui_Dashboard
self.ui = Ui_Dashboard()
self.ui.setupUi(self)
global widgets
widgets = self.ui
# APP NAME
# ///////////////////////////////////////////////////////////////
title = "Notarius - Sistema administrativo"
self.setWindowTitle(title)
centerOnScreen(self)
uiDefinitions(self)
self.ui.leftMenuBg.hide()
# TOGGLE MENU
# ///////////////////////////////////////////////////////////////
widgets.toggleButton.clicked.connect(
lambda: toggleMenu(self.ui, True))
# BUTTON CLICK
widgets.logout.clicked.connect(self.logOut)
# EXTRA LEFT BOX
def openCloseLeftBox():
toggleLeftBox(self.ui, True)
widgets.extraCloseColumnBtn.clicked.connect(openCloseLeftBox)
self.show()
if self.ui.login.exec_() == QtWidgets.QDialog.Accepted:
user, pwd = getUsuarioLogueado()
self.ui.leftMenuBg.show()
checarPermisos(self.ui)
createButtons(self.ui)
self.ui.titleLeftDescription.setText(QCoreApplication.translate(
"MainWindow", f"Usuario: {user}", None))
nombre_btn = getListaBotones()[0][0].lower()
startPage = getattr(self.ui, nombre_btn)
button = getattr(self.ui, f"btn_{nombre_btn}")
self.ui.stackedWidget.setCurrentWidget(startPage)
button.setStyleSheet(selectMenu(button.styleSheet()))
else:
self.close()
# ///////////////////////////////////////////////////////////////
# SET HOME PAGE AND SELECT MENU
# SHOW APP
def logOut(self):
clearSession()
self.return_to_login = True
self.close()
#self.ui.stackedWidget.setCurrentWidget(self.ui.login)
def closeEvent(self, event):
if not self.return_to_login:
sys.exit()
if __name__ == "__main__":
from pages.Login import LoginScreen
app = QtWidgets.QApplication(sys.argv)
app.setWindowIcon(QtGui.QIcon("ui/resources/imagenes/carpeta.png"))
while True:
win = MainWindow()
app.exec_()