1 Star 0 Fork 0

leonyan2020/pyCoating

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Parameter.py 4.93 KB
一键复制 编辑 原始数据 按行查看 历史
leonyan2020 提交于 2021-12-29 12:55 . V0.20
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2020/9/14 12:52
# @Author : leon yan
# @Site :
# @File : Parameter.py
# @Software: PyCharm
from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt
from PyQt5.QtWidgets import (QApplication, QMainWindow, QMessageBox)
import Globalist as gl
from SystemSet import QSystemSet
from SheetTBL import QSheetTBL
from Plc import QPlc
from resource.Parameter_ui import Ui_QWFormTable
class QParameter(QMainWindow, Ui_QWFormTable):
LoginIsOut = pyqtSignal()
def __init__(self, parent=None, *args, **kwargs):
super().__init__(parent, *args, **kwargs)
self.setupUi(self)
# gl.init() # 调试用
self._formatTab()
def __del__(self): # 析构函数
print("Parameter is deleted")
def closeEvent(self, event):
pass
def _formatTab(self):
self.dic_tab = {}
self.tabWidget.setVisible(False)
self.tabWidget.clear() # 清除所有页面
self.tabWidget.setTabsClosable(True) # Page有关闭按钮
self.tabWidget.setDocumentMode(True)
self.on_actParameter_triggered()
@pyqtSlot()
def on_actParameter_triggered(self):
self._showBtnInfo(self.sender())
if "参数" in self.dic_tab:
self.tabWidget.setCurrentIndex(self.dic_tab["参数"])
self.tabWidget.setVisible(True)
return
else:
formDoc = QSystemSet(self)
formDoc.setAttribute(Qt.WA_DeleteOnClose) # 关闭时自动删除
title = "参数"
curIndex = self.tabWidget.addTab(formDoc, title) # 添加到tabWidget
self.tabWidget.setCurrentIndex(curIndex)
self.tabWidget.setVisible(True)
self.dic_tab["参数"] = curIndex
@pyqtSlot()
def on_action_Device_triggered(self):
self._showBtnInfo(self.sender())
if "设备" in self.dic_tab:
self.tabWidget.setCurrentIndex(self.dic_tab["设备"])
self.tabWidget.setVisible(True)
return
else:
formDoc = QSheetTBL("Device")
formDoc.setAttribute(Qt.WA_DeleteOnClose) # 关闭时自动删除
title = "设备"
curIndex = self.tabWidget.addTab(formDoc, title) # 添加到tabWidget
self.tabWidget.setCurrentIndex(curIndex)
self.tabWidget.setVisible(True)
self.dic_tab["设备"] = curIndex
@pyqtSlot()
def on_action_Plc_Monitor_triggered(self):
self._showBtnInfo(self.sender())
if "Plc监控" in self.dic_tab:
self.tabWidget.setCurrentIndex(self.dic_tab["Plc监控"])
self.tabWidget.setVisible(True)
return
else:
formDoc = QPlc()
formDoc.setAttribute(Qt.WA_DeleteOnClose) # 关闭时自动删除
title = "Plc监控"
curIndex = self.tabWidget.addTab(formDoc, title) # 添加到tabWidget
self.tabWidget.setCurrentIndex(curIndex)
self.tabWidget.setVisible(True)
self.dic_tab["Plc监控"] = curIndex
@pyqtSlot()
def on_actUser_triggered(self):
self._showBtnInfo(self.sender())
if "用户管理" in self.dic_tab:
self.tabWidget.setCurrentIndex(self.dic_tab["用户管理"])
self.tabWidget.setVisible(True)
return
formDoc = QSheetTBL("UserTable")
formDoc.setAttribute(Qt.WA_DeleteOnClose) # 关闭时自动删除
title = "用户管理"
curIndex = self.tabWidget.addTab(formDoc, title) # 添加到tabWidget
self.tabWidget.setCurrentIndex(curIndex)
self.tabWidget.setVisible(True)
self.dic_tab["用户管理"] = curIndex
@pyqtSlot()
def on_actLogOut_triggered(self):
self._showBtnInfo(self.sender())
gl.global_var["userVar"]["Admin"] = 0
gl.global_var["userVar"]["LoginUser"] = ""
gl.global_var["userVar"]["LoginUserName"] = ""
gl.global_var["userVar"]["LoginStatus"] = "未登入"
self.LoginIsOut.emit()
QMessageBox.information(self, "提示", "注销成功")
def _showBtnInfo(self, btn):
pass
# 以下是Tab的相关控制
def on_tabWidget_currentChanged(self, index): # tabWidget当前页面变化
# print(self.tabWidget.tabText(index))
self.dic_tab.clear()
cnt = self.tabWidget.count() > 0 # 再无页面时
self.tabWidget.setVisible(cnt)
if cnt != 0:
i = 0
n = self.tabWidget.count()
for i in range(n):
self.dic_tab[self.tabWidget.tabText(i)] = i
i += 1
def on_tabWidget_tabCloseRequested(self, index): # 分页关闭时关闭窗体
self.dic_tab.clear()
if index < 0:
return
aForm = self.tabWidget.widget(index)
aForm.close()
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
objWindow = QParameter()
objWindow.show()
sys.exit(app.exec_())
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/leonyan2020/pyCoating.git
git@gitee.com:leonyan2020/pyCoating.git
leonyan2020
pyCoating
pyCoating
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385