-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
95 lines (67 loc) · 2.79 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
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton
from PyQt5.QtCore import pyqtSlot, QFile, QTextStream
from PyQt5.QtGui import *
from sidebar_ui import Ui_MainWindow
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.icon_only_widget.hide()
self.ui.stackedWidget.setCurrentIndex(0)
self.ui.home_btn_2.setChecked(True)
## Function for searching
def on_search_btn_clicked(self):
self.ui.stackedWidget.setCurrentIndex(5)
search_text = self.ui.search_input.text().strip()
if search_text:
self.ui.label_9.setText(search_text)
## Function for changing page to user page
def on_user_btn_clicked(self):
self.ui.stackedWidget.setCurrentIndex(6)
## Change QPushButton Checkable status when stackedWidget index changed
def on_stackedWidget_currentChanged(self, index):
btn_list = self.ui.icon_only_widget.findChildren(QPushButton) \
+ self.ui.full_menu_widget.findChildren(QPushButton)
for btn in btn_list:
if index in [5, 6]:
btn.setAutoExclusive(False)
btn.setChecked(False)
else:
btn.setAutoExclusive(True)
## functions for changing menu page
def on_home_btn_1_toggled(self):
self.ui.stackedWidget.setCurrentIndex(0)
print("HOME BUTTON 1 TOGGLED")
def on_home_btn_2_toggled(self):
self.ui.stackedWidget.setCurrentIndex(0)
print("HOME BUTTON 2 TOGGLED")
def on_dashborad_btn_1_toggled(self):
self.ui.stackedWidget.setCurrentIndex(1)
print("DASHBOARD BUTTON 1 TOGGLED")
def on_dashborad_btn_2_toggled(self):
self.ui.stackedWidget.setCurrentIndex(1)
print("DASHBOARD BUTTON 2 TOGGLED")
def on_orders_btn_1_toggled(self):
self.ui.stackedWidget.setCurrentIndex(2)
def on_orders_btn_2_toggled(self):
self.ui.stackedWidget.setCurrentIndex(2)
def on_products_btn_1_toggled(self):
self.ui.stackedWidget.setCurrentIndex(3)
def on_products_btn_2_toggled(self, ):
self.ui.stackedWidget.setCurrentIndex(3)
def on_customers_btn_1_toggled(self):
self.ui.stackedWidget.setCurrentIndex(4)
def on_customers_btn_2_toggled(self):
self.ui.stackedWidget.setCurrentIndex(4)
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setWindowIcon(QIcon("assets\\asl-icon.png"))
style_file = QFile("style.qss")
style_file.open(QFile.ReadOnly | QFile.Text)
style_stream = QTextStream(style_file)
app.setStyleSheet(style_stream.readAll())
window = MainWindow()
window.show()
sys.exit(app.exec())