增加主页面

This commit is contained in:
yuruo
2024-03-09 21:43:24 +08:00
parent 203fedf93e
commit 09a065c528
8 changed files with 119 additions and 11 deletions

View File

@@ -1,9 +1,11 @@
from typing import Type
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QHBoxLayout, QLabel, QLineEdit, QWidget, QPushButton
from langchain_core.tools import StructuredTool
from pydantic import BaseModel
from pages.action_list_view import GlobalUtil, ActionListViewItem
from pages.edit_action_list_view import GlobalUtil, ActionListViewItem
from utils.qt_util import QtUtil

View File

@@ -4,12 +4,10 @@ import sys
import leancloud
from PyQt6.QtWidgets import QApplication
from langchain.agents import create_openai_functions_agent, AgentExecutor
from langchain_core.prompts import ChatPromptTemplate, SystemMessagePromptTemplate, MessagesPlaceholder, PromptTemplate, \
HumanMessagePromptTemplate
from pages.action_list_view import GlobalUtil
from pages.edit_action_list_view import GlobalUtil
from pages.edit_page import EditPage
from pages.func_list_page import FuncListPage
from pages.login_page import LoginPage
from utils.config import Config
@@ -43,6 +41,6 @@ class AutoMate:
if __name__ == "__main__":
app = QApplication(sys.argv)
GlobalUtil.init()
page = EditPage()
page = FuncListPage()
page.show()
sys.exit(app.exec())

View File

@@ -1,6 +1,7 @@
from PyQt6.QtCore import Qt, QMimeData, QByteArray, QPoint
from PyQt6.QtGui import QDrag
from PyQt6.QtWidgets import QListWidget, QListWidgetItem, QApplication, QStyle
from pages.styled_item_delegate import StyledItemDelegate

View File

@@ -1,6 +1,6 @@
from pages.bse_page import BasePage
from pages.edit_action_list_view import GlobalUtil
from pages.edit_function_page import FunctionListView
from pages.action_list_view import GlobalUtil
from utils.qt_util import QtUtil
@@ -15,11 +15,9 @@ class EditPage(BasePage):
self.ui.ListViewLayout.setStretch(0, 1)
self.ui.ListViewLayout.setStretch(1, 2)
self.ui.ListViewLayout.setStretch(2, 10)
self.ui.show()
def __run_button_click(self):
GlobalUtil.action_list_global.model()
for index in range(GlobalUtil.action_list_global.count()):
func = GlobalUtil.action_list_global.item(index)
r = func.__getattribute__("func").run_with_out_arg()
print(r)

50
pages/func_list_page.py Normal file
View File

@@ -0,0 +1,50 @@
from PyQt6.QtCore import QSize
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import QPushButton, QGraphicsOpacityEffect
from pages.bse_page import BasePage
from pages.edit_page import EditPage
from utils.qt_util import QtUtil
class AddFuncButton(QPushButton):
def __init__(self, pos_x, pos_y, func_list_page):
super().__init__()
self.pos_x = pos_x
self.pos_y = pos_y
self.func_list_page = func_list_page
self.setMouseTracking(True)
self.clicked.connect(self.click)
self.setIcon(QIcon(QtUtil.get_icon("添加.png")))
self.setIconSize(QSize(50, 50))
self.setFlat(True) # 删除按钮边框
# 按钮消息
self.opacity_effect = QGraphicsOpacityEffect(self)
self.setGraphicsEffect(self.opacity_effect)
self.opacity_effect.setOpacity(0)
def click(self):
self.func_list_page.hide()
EditPage().show()
def enterEvent(self, event):
self.opacity_effect.setOpacity(1)
def leaveEvent(self, event):
self.opacity_effect.setOpacity(0)
class FuncListPage(BasePage):
def setup_up(self):
self.ui = QtUtil.load_ui("func_list_page.ui")
# 四行三列,辅满通用应用列表布局
for i in range(3): # 3行
for j in range(4): # 4列
add_button = AddFuncButton(i, j, self.ui)
self.ui.general_layout.addWidget(add_button, i, j)
# 四行四列,辅满专属应用列表布局
for i in range(3): # 4行
for j in range(4): # 4列
add_button = AddFuncButton(i, j, self.ui)
self.ui.special_layout.addWidget(add_button, i, j)

54
pages/func_list_page.ui Normal file
View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>353</width>
<height>621</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>351</width>
<height>241</height>
</rect>
</property>
<layout class="QGridLayout" name="general_layout"/>
</widget>
<widget class="QWidget" name="gridLayoutWidget_2">
<property name="geometry">
<rect>
<x>0</x>
<y>270</y>
<width>351</width>
<height>321</height>
</rect>
</property>
<layout class="QGridLayout" name="special_layout"/>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>353</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

BIN
source/添加.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

@@ -1,7 +1,6 @@
import os
from PyQt6 import uic
from PyQt6.QtWidgets import QWidget
class QtUtil:
@@ -10,4 +9,10 @@ class QtUtil:
# 项目根目录
project_root_path = os.path.abspath(os.path.dirname(__file__))
path = os.path.join(project_root_path, "..", "pages", *path)
return uic.loadUi(path)
return uic.loadUi(path)
@staticmethod
def get_icon(*path):
project_root_path = os.path.abspath(os.path.dirname(__file__))
path = os.path.join(project_root_path, "..", "source", *path)
return path