Compare commits

...

3 Commits

3 changed files with 2573 additions and 46 deletions

File diff suppressed because it is too large Load Diff

1235
cood_forms_interface.py Normal file

File diff suppressed because it is too large Load Diff

149
main.py
View File

@ -1,11 +1,39 @@
# coding:utf-8 # coding:utf-8
import sys import sys
from PySide6.QtCore import Qt, QRect, QUrl import os
from PySide6.QtGui import QIcon, QPainter, QImage, QBrush, QColor, QFont, QDesktopServices import sqlite3
from PySide6.QtWidgets import QApplication, QFrame, QStackedWidget, QHBoxLayout, QLabel from PySide6.QtCore import Qt, QRect, QUrl, Signal
from PySide6.QtGui import (
QIcon,
QPainter,
QImage,
QBrush,
QColor,
QFont,
QDesktopServices,
)
from PySide6.QtWidgets import (
QApplication,
QFrame,
QStackedWidget,
QHBoxLayout,
QLabel,
QWidget,
)
from qfluentwidgets import (NavigationInterface, NavigationItemPosition, NavigationWidget, MessageBox, from qfluentwidgets import (
isDarkTheme, setTheme, Theme, setThemeColor, qrouter, FluentWindow, NavigationAvatarWidget) NavigationInterface,
NavigationItemPosition,
NavigationWidget,
MessageBox,
isDarkTheme,
setTheme,
Theme,
setThemeColor,
qrouter,
FluentWindow,
NavigationAvatarWidget,
)
from qfluentwidgets import FluentIcon as FIF from qfluentwidgets import FluentIcon as FIF
from qframelesswindow import FramelessWindow, StandardTitleBar from qframelesswindow import FramelessWindow, StandardTitleBar
@ -14,6 +42,9 @@ from app.view.produce_interface import ProduceInterface
from app.view.text_interface import TextInterface from app.view.text_interface import TextInterface
from app.view.data_interface import DataInterface from app.view.data_interface import DataInterface
from app.view.cood_forms_interface import CoodFormsInterface
class Widget(QFrame): class Widget(QFrame):
def __init__(self, text: str, parent=None): def __init__(self, text: str, parent=None):
@ -22,11 +53,12 @@ class Widget(QFrame):
self.label.setAlignment(Qt.AlignCenter) self.label.setAlignment(Qt.AlignCenter)
self.hBoxLayout = QHBoxLayout(self) self.hBoxLayout = QHBoxLayout(self)
self.hBoxLayout.addWidget(self.label, 1, Qt.AlignCenter) self.hBoxLayout.addWidget(self.label, 1, Qt.AlignCenter)
self.setObjectName(text.replace(' ', '-')) self.setObjectName(text.replace(" ", "-"))
class Window(FramelessWindow): class Window(FramelessWindow):
## 定义信号:调整高度
heightChanged = Signal(int)
def __init__(self): def __init__(self):
super().__init__() super().__init__()
@ -43,15 +75,15 @@ class Window(FramelessWindow):
self.stackWidget = QStackedWidget(self) self.stackWidget = QStackedWidget(self)
# create sub interface # create sub interface
# self.system = SystemInterface(self) self.system = SystemInterface(self)
# self.product = ProduceInterface(self) self.product = ProduceInterface(self)
# self.robot = Widget('机械臂基础设置', self) self.robot = Widget("机械臂基础设置", self) # 暂时不用
# self.io = Widget('IO面板', self) self.io = Widget("IO面板", self) # 需要完成
# self.position = Widget('位置设定', self) self.position = CoodFormsInterface(self) # 位置设定
# self.basic = Widget('基础设置', self) self.basic = Widget("基础设置", self) # 需要完成
# self.point = Widget('点位调试', self) self.point = Widget("点位调试", self)
# self.other = Widget('其他设置', self) self.other = Widget("其他设置", self)
self.data=DataInterface(self) self.data = DataInterface(self)
# initialize layout # initialize layout
self.initLayout() self.initLayout()
@ -73,18 +105,30 @@ class Window(FramelessWindow):
# self.navigationInterface.setAcrylicEnabled(True) # self.navigationInterface.setAcrylicEnabled(True)
# self.addSubInterface 加入导航栏页面 # self.addSubInterface 加入导航栏页面
# self.addSubInterface(self.system, FIF.SETTING, '系统设置', NavigationItemPosition.SCROLL) self.addSubInterface(
# self.addSubInterface(self.product, FIF.COMPLETED, '生产界面', parent=self.system) self.system, FIF.SETTING, "系统设置", NavigationItemPosition.SCROLL
# self.addSubInterface(self.robot, FIF.ROBOT, '机械臂基础设置', parent=self.system) )
# self.addSubInterface(self.io, FIF.GAME, 'IO面板', parent=self.system) self.addSubInterface(
# self.addSubInterface(self.position, FIF.IOT, '位置设定', parent=self.system) self.product, FIF.COMPLETED, "生产界面", parent=self.system
# self.addSubInterface(self.basic, FIF.DEVELOPER_TOOLS, '基础设置', parent=self.system) )
# self.addSubInterface(self.point, FIF.MOVE, '点位调试', parent=self.system) self.addSubInterface(
# self.robot, FIF.ROBOT, "机械臂基础设置", parent=self.system
# self.navigationInterface.addSeparator() )
#self.addSubInterface(self.other, FIF.APPLICATION, '其他设置', NavigationItemPosition.SCROLL) self.addSubInterface(self.io, FIF.GAME, "IO面板", parent=self.system)
self.addSubInterface(self.position, FIF.IOT, "位置设定", parent=self.system)
self.addSubInterface(self.data, FIF.PHOTO, '数据采集', NavigationItemPosition.SCROLL) self.addSubInterface(
self.basic, FIF.DEVELOPER_TOOLS, "基础设置", parent=self.system
)
self.addSubInterface(self.point, FIF.MOVE, "点位调试", parent=self.system)
# self.navigationInterface.addSeparator()
self.addSubInterface(
self.other, FIF.APPLICATION, "其他设置", NavigationItemPosition.SCROLL
)
self.addSubInterface(
self.data, FIF.PHOTO, "数据采集", NavigationItemPosition.SCROLL
)
# add navigation items to scroll area # add navigation items to scroll area
# for i in range(1, 21): # for i in range(1, 21):
# self.navigationInterface.addItem( # self.navigationInterface.addItem(
@ -97,8 +141,8 @@ class Window(FramelessWindow):
# add custom widget to bottom # add custom widget to bottom
self.navigationInterface.addWidget( self.navigationInterface.addWidget(
routeKey='avatar', routeKey="avatar",
widget=NavigationAvatarWidget('zhiyiYo', 'resource/shoko.png'), widget=NavigationAvatarWidget("zhiyiYo", "resource/shoko.png"),
onClick=self.showMessageBox, onClick=self.showMessageBox,
position=NavigationItemPosition.BOTTOM, position=NavigationItemPosition.BOTTOM,
) )
@ -117,13 +161,13 @@ class Window(FramelessWindow):
def initWindow(self): def initWindow(self):
self.resize(900, 700) self.resize(900, 700)
self.setWindowIcon(QIcon('resource/logo.png')) self.setWindowIcon(QIcon("resource/logo.png"))
self.setWindowTitle('密胺投料控制系统') self.setWindowTitle("密胺投料控制系统")
self.titleBar.setAttribute(Qt.WA_StyledBackground) self.titleBar.setAttribute(Qt.WA_StyledBackground)
desktop = QApplication.screens()[0].availableGeometry() desktop = QApplication.screens()[0].availableGeometry()
w, h = desktop.width(), desktop.height() w, h = desktop.width(), desktop.height()
self.move(w//2 - self.width()//2, h//2 - self.height()//2) self.move(w // 2 - self.width() // 2, h // 2 - self.height() // 2)
# NOTE: set the minimum window width that allows the navigation panel to be expanded # NOTE: set the minimum window width that allows the navigation panel to be expanded
self.navigationInterface.setMinimumExpandWidth(900) self.navigationInterface.setMinimumExpandWidth(900)
@ -131,8 +175,15 @@ class Window(FramelessWindow):
self.setQss() self.setQss()
def addSubInterface(self, interface, icon, text: str, position=NavigationItemPosition.TOP, parent=None): def addSubInterface(
""" add sub interface """ self,
interface,
icon,
text: str,
position=NavigationItemPosition.TOP,
parent=None,
):
"""add sub interface"""
self.stackWidget.addWidget(interface) self.stackWidget.addWidget(interface)
self.navigationInterface.addItem( self.navigationInterface.addItem(
routeKey=interface.objectName(), routeKey=interface.objectName(),
@ -141,12 +192,12 @@ class Window(FramelessWindow):
onClick=lambda: self.switchTo(interface), onClick=lambda: self.switchTo(interface),
position=position, position=position,
tooltip=text, tooltip=text,
parentRouteKey=parent.objectName() if parent else None parentRouteKey=parent.objectName() if parent else None,
) )
def setQss(self): def setQss(self):
color = 'dark' if isDarkTheme() else 'light' color = "dark" if isDarkTheme() else "light"
with open(f'resource/{color}/demo.qss', encoding='utf-8') as f: with open(f"resource/{color}/demo.qss", encoding="utf-8") as f:
self.setStyleSheet(f.read()) self.setStyleSheet(f.read())
def switchTo(self, widget): def switchTo(self, widget):
@ -158,22 +209,28 @@ class Window(FramelessWindow):
#!IMPORTANT: This line of code needs to be uncommented if the return button is enabled #!IMPORTANT: This line of code needs to be uncommented if the return button is enabled
# qrouter.push(self.stackWidget, widget.objectName()) # qrouter.push(self.stackWidget, widget.objectName())
def resizeEvent(self, event):
super().resizeEvent(event)
self.heightChanged.emit(self.height())
def showMessageBox(self): def showMessageBox(self):
w = MessageBox( w = MessageBox(
'支持作者🥰', "支持作者🥰",
'个人开发不易,如果这个项目帮助到了您,可以考虑请作者喝一瓶快乐水🥤。您的支持就是作者开发和维护项目的动力🚀', "个人开发不易,如果这个项目帮助到了您,可以考虑请作者喝一瓶快乐水🥤。您的支持就是作者开发和维护项目的动力🚀",
self self,
) )
w.yesButton.setText('来啦老弟') w.yesButton.setText("来啦老弟")
w.cancelButton.setText('下次一定') w.cancelButton.setText("下次一定")
if w.exec(): if w.exec():
QDesktopServices.openUrl(QUrl("https://afdian.net/a/zhiyiYo")) QDesktopServices.openUrl(QUrl("https://afdian.net/a/zhiyiYo"))
if __name__ == '__main__': if __name__ == "__main__":
app = QApplication(sys.argv) # 初始化数据库
# init_database()
app = QApplication([])
w = Window() w = Window()
w.show() w.show()
app.exec() app.exec()