from PyQt5.QtGui import QPixmap
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import *
import sys
import qtawesome
from openpyxl import *
import re
class Test_1(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.init_ui1()
self.Gly = 0
self.showselect = 0
def init_ui1(self):
# 主体
self.setFixedSize(1200, 900) #设置窗口大小
self.main_widget = QtWidgets.QWidget() # 创建窗口主部件
self.main_layout = QtWidgets.QGridLayout() # 创建主部件的网格布局
self.main_widget.setLayout(self.main_layout) # 设置窗口主部件布局为网格布局
self.left_widget = QtWidgets.QWidget() # 创建左侧部件
self.left_widget.setObjectName('left_widget')
self.left_layout = QtWidgets.QGridLayout() # 创建左侧部件的网格布局层
self.left_widget.setLayout(self.left_layout) # 设置左侧部件布局为网格
self.right_widget = QtWidgets.QWidget() # 创建右侧部件
self.right_widget.setObjectName('right_widget')
self.right_layout = QtWidgets.QGridLayout()
self.right_widget.setLayout(self.right_layout) # 设置右侧部件布局为网格
self.main_layout.addWidget(self.left_widget, 0, 0, 12, 2) # 左侧部件在第0行第0列,占8行3列
self.main_layout.addWidget(self.right_widget, 0, 2, 12, 10) # 右侧部件在第0行第3列,占8行9列
self.setCentralWidget(self.main_widget) # 设置窗口主部件
# 左侧栏
self.left_close = QtWidgets.QPushButton(qtawesome.icon('fa.remove', color='white'), "") # 关闭按钮
self.left_close.clicked.connect(self.onClickButton) # 点击关闭按钮后关闭程序。
self.left_mini = QtWidgets.QPushButton(qtawesome.icon('fa.circle', color='white'), "") # 放大缩小按钮
self.left_mini.clicked.connect(self.onClickzuida)
self.left_zuixiao = QtWidgets.QPushButton(qtawesome.icon('fa.minus', color='white'), "") # 最小化按钮
self.left_zuixiao.clicked.connect(self.onClickzuixiao)
# self.left_close.clicked.connect(self.onClickButton) # 点击关闭按钮后关闭程序。
self.left_label_1 = QtWidgets.QPushButton("管理员")
self.left_label_1.setObjectName('left_label')
self.left_label_2 = QtWidgets.QPushButton("信息操作")
self.left_label_2.setObjectName('left_label')
self.left_label_3 = QtWidgets.QPushButton("联系与帮助")
self.left_label_3.setObjectName('left_label')
self.left_button_1 = QtWidgets.QPushButton(qtawesome.icon('fa.circle', color='gray'), "登陆")
self.left_button_1.setObjectName('left_button')
self.left_button_2 = QtWidgets.QPushButton(qtawesome.icon('fa.cloud-download', color='gray'), "添加场馆")
self.left_button_2.setObjectName('left_button')
self.left_button_2.clicked.connect(self.tes_2)
self.left_button_3 = QtWidgets.QPushButton(qtawesome.icon('fa.wrench', color='gray'), "修改场馆")
self.left_button_3.setObjectName('left_button')
self.left_button_3.clicked.connect(self.tes_3)
self.left_button_4 = QtWidgets.QPushButton(qtawesome.icon('fa.search', color='gray'), "查询场馆")
self.left_button_4.setObjectName('left_button')
self.left_button_4.clicked.connect(self.tes_4)
self.left_button_5 = QtWidgets.QPushButton(qtawesome.icon('fa.trash', color='gray'), "删除场馆")
self.left_button_5.setObjectName('left_button')
self.left_button_5.clicked.connect(self.tes_5)
self.left_button_6 = QtWidgets.QPushButton(qtawesome.icon('fa.signal', color='gray'), "预定场馆")
self.left_button_6.setObjectName('left_button')
self.left_button_6.clicked.connect(self.tes_6)
self.left_button_7 = QtWidgets.QPushButton(qtawesome.icon('fa.comment', color='gray'), "关于")
self.left_button_7.setObjectName('left_button')
self.left_button_7.clicked.connect(self.tes_7)
self.left_button_8 = QtWidgets.QPushButton(qtawesome.icon('fa.star', color='gray'), "说明")
self.left_button_8.setObjectName('left_button')
self.left_button_8.clicked.connect(self.tes_8)
self.left_button_9 = QtWidgets.QPushButton(qtawesome.icon('fa.question', color='gray'), "联系方式")
self.left_button_9.setObjectName('left_button')
self.left_button_9.clicked.connect(self.tes_9)
# self.left_xxx = QtWidgets.QPushButton(" ")
self.left_layout.addWidget(self.left_mini, 0, 2, 1, 1)
self.left_layout.addWidget(self.left_close, 0, 0, 1, 1)
self.left_layout.addWidget(self.left_zuixiao, 0, 1, 1, 1)
self.left_layout.addWidget(self.left_label_1, 1, 0, 1, 3)
self.left_layout.addWidget(self.left_button_1, 2, 0, 1, 3)
self.left_layout.addWidget(self.left_label_2, 3, 0, 1, 3)
self.left_layout.addWidget(self.left_button_2, 4, 0, 1, 3)
self.left_layout.addWidget(self.left_button_3, 5, 0, 1, 3)
self.left_layout.addWidget(self.left_button_4, 6, 0, 1, 3)
self.left_layout.addWidget(self.left_button_5, 7, 0, 1, 3)
self.left_layout.addWidget(self.left_button_6, 8, 0, 1, 3)
self.left_layout.addWidget(self.left_label_3, 9, 0, 1, 3)
self.left_layout.addWidget(self.left_button_7, 10, 0, 1, 3)
self.left_layout.addWidget(self.left_button_8, 11, 0, 1, 3)
self.left_layout.addWidget(self.left_button_9, 12, 0, 1, 3)
self.left_close.setFixedSize(20, 20) # 设置关闭按钮的大小
self.left_mini.setFixedSize(20, 20) # 设置最小化按钮大小
self.left_zuixiao.setFixedSize(20, 20) # 设置最小化按钮大小
self.left_close.setStyleSheet(
'''QPushButton{background:gray;border-radius:5px;}QPushButton:hover{background:red;}''')
self.left_mini.setStyleSheet(
'''QPushButton{background:gray;border-radius:5px;}QPushButton:hover{background:green;}''')
self.left_zuixiao.setStyleSheet(
'''QPushButton{background:gray;border-radius:5px;}QPushButton:hover{background:green;}''')
# # 右侧栏
# self.right_bar_widget = QtWidgets.QWidget() # 右侧顶部搜索框部件
# self.right_bar_layout = QtWidgets.QGridLayout() # 右侧顶部搜索框网格布局
#
# self.right_bar_widget.setLayout(self.right_bar_layout)
# self.right_layout.addWidget(self.right_bar_widget, 3, 0, 10, 9)
#
# self.right_label_4 = QtWidgets.QPushButton("账号:")
# self.right_label_4.setObjectName('right_label')
# self.right_line_4 = QtWidgets.QLineEdit()
# self.right_line_4.setObjectName('right_line')
#
# self.right_label_0 = QtWidgets.QPushButton("密码:")
# self.right_label_0.setObjectName('right_label')
# self.right_line_0 = QtWidgets.QLineEdit()
# self.right_line_0.setObjectName('right_line')
# self.right_line_0.setEchoMode(QtWidgets.QLineEdit.Password)
#
# self.right_button_1 = QtWidgets.QPushButton(qtawesome.icon('fa.circle', color='gray'), "登陆")
# self.right_button_1.setObjectName('right_button')
# self.right_button_1.clicked.connect(self.denglu)
#
# self.right_layout.addWidget(self.right_label_4, 0, 1, 1, 1)
# self.right_layout.addWidget(self.right_line_4, 0, 0, 1, 1)
# self.right_layout.addWidget(self.right_label_0, 1, 1, 1, 1)
# self.right_layout.addWidget(self.right_line_0, 1, 0, 1, 1)
# self.right_layout.addWidget(self.right_button_1, 2, 1, 1, 1)
#
# # 左侧Qss美化
# self.left_widget.setStyleSheet('''
# QPushButton{border:none;color:gray;}
# QPushButton#left_label{
# border:none;
# border-bottom:1px solid white;
# font-size:18px;
# font-weight:700;
# font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
# }
#
# QPushButton#left_button:hover{border-left:4px solid red;font-weight:700;}
#
# QWidget#left_widget{
# background:Pink;
# border-top:1px solid white;
# border-bottom:1px solid white;
# border-left:1px solid white;
# border-top-left-radius:10px;
# border-bottom-left-radius:10px;
# }
# ''')
# # 右侧Qss美化
# self.right_widget.setStyleSheet('''
# QPushButton{border:none;color:black;}
# QPushButton#right_label{
# border:none;
# border-bottom:2px solid black;
# font-size:18px;
# font-weight:700;
# font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
# }
# QPushButton#right_button:hover{border-left:6px solid red;font-weight:700;border-right:6px solid red;}
#
# QWidget#right_widget{
# border-image:url('Background/background.png');
# border-top:3px solid #ffffcc;
# border-bottom:3px solid #ffffcc;
# border-left:3px solid #ffffcc;
# border-right:3px solid #ffffcc;
# border-top-right-radius:10px;
# border-bottom-right-radius:10px;
# }
#
# QLineEdit#right_line{
# font-size:18px;
# font-weight:700;
# border:none;
# font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
# border-top:2px solid #4B0082;
# border-bottom:2px solid #4B0082;
# border-left:2px solid #4B0082;
# border-right:2px solid #4B0082;
# border-top-left-radius:10px;
# border-bottom-left-radius:10px;
# border-top-right-radius:10px;
# border-bottom-right-radius:10px;
# }
# ''')
#
# self.setWindowOpacity(0.97) # 设置窗口透明度
# self.setAttribute(QtCore.Qt.WA_TranslucentBackground) # 设置窗口背景透明
# self.setWindowFlag(QtCore.Qt.FramelessWindowHint) # 隐藏边框
# self.main_layout.setSpacing(0)
#
def onClickButton(self): # 定义按钮点击的槽函数
self.close()
def onClickzuixiao(self):
self.showMinimized() # 最小化
def onClickzuida(self):
print(self.showselect)
self.showselect = self.showselect + 1
if self.showselect % 2 != 0:
self.showMaximized() # 缩放 最大
else:
self.showNormal()
# 鼠标按下事件
def mousePressEvent(self, evt):
# 获取全局的X、Y值
self.mouse_X = evt.globalX()
self.mouse_Y = evt.globalY()
# 获取局部的X、Y值
self.origin_x = self.x()
self.origin_y = self.y()
# 鼠标谈起事件
def mouseReleaseEvent(self, evt):
pass
# 鼠标移动事件
def mouseMoveEvent(self, evt):
# 移动后的X、Y值减去移动前的X、Y值 就是移动值
move_x = evt.globalX() - self.mouse_X
move_y = evt.globalY() - self.mouse_Y
# 局部值加上移动值就是移动后的窗口位置
dest_x = self.origin_x + move_x
dest_y = self.origin_y + move_y
gui.move(dest_x, dest_y)
def denglu(self):
try:
if str(self.right_line_4.text()) == 'admin' and str(self.right_line_0.text()) == '00123':
self.Gly = 1
msg_box = QMessageBox(QMessageBox.Warning, '提示', '登陆成功!')
msg_box.exec_()
self.right_line_0.setText(' ')
self.right_line_4.setText(' ')
else:
msg_box = QMessageBox(QMessageBox.Warning, '警告', '账号或密码错误!')
msg_box.exec_()
except:
msg_box = QMessageBox(QMessageBox.Warning, '警告', '账号密码不为空!')
msg_box.exec_()
def tes_2(self):
if self.Gly == 1:
self.t2 = Test_2()
self.hide()
self.t2.show()
else:
msg_box = QMessageBox(QMessageBox.Warning, '警告', '无管理员权限!')
msg_box.exec_()
def tes_3(self):
if self.Gly == 1:
self.t2 = Test_3()
self.hide()
self.t2.show()
else:
msg_box = QMessageBox(QMessageBox.Warning, '警告', '无管理员权限!')
msg_box.exec_()
def tes_4(self):
if self.Gly == 1:
self.t2 = Test_4()
self.hide()
self.t2.show()
else:
msg_box = QMessageBox(QMessageBox.Warning, '警告', '无管理员权限!')
msg_box.exec_()
def tes_5(self):
if self.Gly == 1:
self.t2 = Test_5()
self.hide()
self.t2.show()
else:
msg_box = QMessageBox(QMessageBox.Warning, '警告', '无管理员权限!')
msg_box.exec_()
def tes_6(self):
if self.Gly == 1:
self.t2 = Test_6()
self.hide()
self.t2.show()
else:
msg_box = QMessageBox(QMessageBox.Warning, '警告', '无管理员权限!')
msg_box.exec_()
def tes_7(self):
msg_box = QMessageBox(QMessageBox.Warning, '提示', '暂未开发!')
msg_box.exec_()
def tes_8(self):
msg_box = QMessageBox(QMessageBox.Warning, '提示', '暂未开发!')
msg_box.exec_()
def tes_9(self):
msg_box = QMessageBox(QMessageBox.Warning, '提示', '暂未开发!')
msg_box.exec_()
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
gui = Test_1()
gui.show()
sys.exit(app.exec_())
|