Compare commits

...

5 Commits

Author SHA1 Message Date
75750180cc 修改配色 & 静态资源 & 软件名 2025-05-28 23:04:53 +08:00
735a8e9a51 添加构建时间 2025-05-27 02:40:12 +08:00
31b73937fe 修改部分静态资源 2025-05-27 02:01:46 +08:00
b78f35101b 新增依赖项 2025-05-26 19:49:31 +08:00
56de8390e5 解决控制台乱码 2025-05-26 19:48:31 +08:00
17 changed files with 14258 additions and 13209 deletions

3
.gitignore vendored
View File

@@ -5,4 +5,5 @@ dist
.idea .idea
__pycache__ __pycache__
*.pyc *.pyc
files files
build_info.py

View File

@@ -1,5 +1,6 @@
@echo off @echo off
setlocal setlocal
chcp 65001
echo === 尝试激活虚拟环境 === echo === 尝试激活虚拟环境 ===
if exist ".venv\Scripts\activate.bat" ( if exist ".venv\Scripts\activate.bat" (
@@ -25,6 +26,7 @@ if errorlevel 1 (
) )
echo === 使用 pyinstaller 构建 === echo === 使用 pyinstaller 构建 ===
python .\utils\hook.py
pyinstaller .\main.spec pyinstaller .\main.spec
if errorlevel 1 ( if errorlevel 1 (
echo [错误] 构建失败! echo [错误] 构建失败!

BIN
images/3rd/qt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 206 KiB

After

Width:  |  Height:  |  Size: 210 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 432 KiB

After

Width:  |  Height:  |  Size: 304 KiB

16
main.py
View File

@@ -1,20 +1,18 @@
import sys import sys
import module.resources
from PySide6.QtWidgets import QApplication from PySide6.QtWidgets import QApplication
from ui.main import MainWindow from ui.main import MainWindow
import module.resources from utils.function import is_frozen
if __name__ == '__main__': if __name__ == '__main__':
app = QApplication(sys.argv) if is_frozen():
window = MainWindow()
try:
import pyi_splash import pyi_splash
pyi_splash.close() pyi_splash.update_text('正在启动...')
except ImportError:
pass
finally:
window.show()
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec()) sys.exit(app.exec())

View File

@@ -20,7 +20,7 @@ splash = Splash(
'images\\splash.png', 'images\\splash.png',
binaries=a.binaries, binaries=a.binaries,
datas=a.datas, datas=a.datas,
text_pos=(5,378), text_pos=(35, 378),
text_size=12, text_size=12,
text_color='black', text_color='black',
minify_script=True, minify_script=True,
@@ -47,6 +47,6 @@ exe = EXE(
target_arch=None, target_arch=None,
codesign_identity=None, codesign_identity=None,
entitlements_file=None, entitlements_file=None,
name='建工工具箱', name='教学工具箱',
icon=['images\\logo.png'], icon=['images\\logo.png'],
) )

File diff suppressed because it is too large Load Diff

View File

@@ -3,4 +3,6 @@ pyside6~=6.9.0
python-docx~=1.1.2 python-docx~=1.1.2
matplotlib~=3.10.3 matplotlib~=3.10.3
PySide6-Fluent-Widgets[full] PySide6-Fluent-Widgets[full]
packaging~=25.0 packaging~=25.0
pyinstaller
pywin32

View File

@@ -2,5 +2,7 @@
<RCC version="1.0"> <RCC version="1.0">
<qresource> <qresource>
<file>./images/logo.png</file> <file>./images/logo.png</file>
<file>./images/3rd/qfluentwidgets.png</file>
<file>./images/3rd/qt.png</file>
</qresource> </qresource>
</RCC> </RCC>

2
ui/__init__.py Normal file
View File

@@ -0,0 +1,2 @@
MAIN_THEME_COLOR = "#0064b0"
BLUE_BACKGROUND_COLOR = "#dbeafe"

View File

@@ -1,9 +1,11 @@
from PySide6.QtGui import QIcon from PySide6.QtGui import QIcon, QShowEvent
from qfluentwidgets import FluentIcon, MSFluentWindow, NavigationItemPosition, MessageBox from qfluentwidgets import FluentIcon, MSFluentWindow, NavigationItemPosition, MessageBox, setThemeColor
from ui import MAIN_THEME_COLOR, BLUE_BACKGROUND_COLOR
from ui.pyui.about_ui import AboutWidget from ui.pyui.about_ui import AboutWidget
from ui.pyui.achievement_ui import AchievementWidget from ui.pyui.achievement_ui import AchievementWidget
from ui.pyui.defense_ui import DefenseWidget from ui.pyui.defense_ui import DefenseWidget
from ui.pyui.picker_ui import PickerWidget
from ui.pyui.test_ui import TestWidget from ui.pyui.test_ui import TestWidget
from utils.function import is_frozen from utils.function import is_frozen
@@ -12,9 +14,13 @@ class MainWindow(MSFluentWindow):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
setThemeColor(MAIN_THEME_COLOR)
self.setCustomBackgroundColor(BLUE_BACKGROUND_COLOR, BLUE_BACKGROUND_COLOR)
self.achievementInterface = AchievementWidget('Achievement Interface', self) self.achievementInterface = AchievementWidget('Achievement Interface', self)
self.defenseInterface = DefenseWidget('Defense Interface', self) self.defenseInterface = DefenseWidget('Defense Interface', self)
self.aboutInterface = AboutWidget('About Interface', self) self.aboutInterface = AboutWidget('About Interface', self)
self.pickerInterface = PickerWidget('Picker Interface', self)
if not is_frozen(): if not is_frozen():
self.testInterface = TestWidget('Test Interface', self) self.testInterface = TestWidget('Test Interface', self)
@@ -27,6 +33,7 @@ class MainWindow(MSFluentWindow):
def initNavigation(self): def initNavigation(self):
self.addSubInterface(self.achievementInterface, FluentIcon.SPEED_HIGH, '达成度') self.addSubInterface(self.achievementInterface, FluentIcon.SPEED_HIGH, '达成度')
self.addSubInterface(self.defenseInterface, FluentIcon.FEEDBACK, '答辩') self.addSubInterface(self.defenseInterface, FluentIcon.FEEDBACK, '答辩')
self.addSubInterface(self.pickerInterface, FluentIcon.PEOPLE, '抽答')
if not is_frozen(): if not is_frozen():
self.addSubInterface(self.testInterface, FluentIcon.VIEW, '测试') self.addSubInterface(self.testInterface, FluentIcon.VIEW, '测试')
@@ -34,8 +41,15 @@ class MainWindow(MSFluentWindow):
def initWindow(self): def initWindow(self):
self.resize(900, 700) self.resize(900, 700)
self.setWindowTitle('建工工具箱') self.setWindowTitle('教学工具箱')
self.setWindowIcon(QIcon(':/images/logo.png')) self.setWindowIcon(QIcon(':/images/logo.png'))
def showError(self, title: str, message: str): def showError(self, title: str, message: str):
MessageBox(title, message, self).exec() MessageBox(title, message, self).exec()
def showEvent(self, event: QShowEvent):
super().showEvent(event)
if is_frozen():
import pyi_splash
pyi_splash.update_text('正在加载...')
pyi_splash.close()

View File

@@ -3,6 +3,7 @@ from PySide6.QtWidgets import QVBoxLayout, QHBoxLayout
from qfluentwidgets import PrimaryPushSettingCard, FluentIcon, GroupHeaderCardWidget, PushButton, ImageLabel, TitleLabel from qfluentwidgets import PrimaryPushSettingCard, FluentIcon, GroupHeaderCardWidget, PushButton, ImageLabel, TitleLabel
from ui.components.widget import Widget from ui.components.widget import Widget
from utils.function import is_frozen
class AboutWidget(Widget): class AboutWidget(Widget):
@@ -11,17 +12,23 @@ class AboutWidget(Widget):
self.logoImage = ImageLabel(':/images/logo.png') self.logoImage = ImageLabel(':/images/logo.png')
self.logoImage.scaledToHeight(100) self.logoImage.scaledToHeight(100)
self.appNameLabel = TitleLabel('建工工具箱🛠️') self.appNameLabel = TitleLabel('教学工具箱 🛠️')
self.hBox = QHBoxLayout() self.hBox = QHBoxLayout()
self.hBox.addWidget(self.logoImage, 0, Qt.AlignLeft) self.hBox.addWidget(self.logoImage, 0, Qt.AlignLeft)
self.hBox.addWidget(self.appNameLabel, 1, Qt.AlignLeft) self.hBox.addWidget(self.appNameLabel, 1, Qt.AlignLeft)
build_time_str = ''
if is_frozen():
from build_info import BUILD_TIME
build_time_str = f",构建时间:{BUILD_TIME}"
self.version_card = PrimaryPushSettingCard( self.version_card = PrimaryPushSettingCard(
text="获取源码", text="获取源码",
icon=FluentIcon.INFO, icon=FluentIcon.INFO,
title="关于", title="关于",
content="作者许方杰。当前版本1.0.0\n本软件使用 GPLv3 开源协议进行分发,作者不对使用本软件造成的任何损失负责。" content=f"作者许方杰。当前版本1.0.0{build_time_str}\n"
f"本软件使用 GPLv3 开源协议进行分发,作者不对使用本软件造成的任何损失负责。"
) )
self.button_list = [ self.button_list = [
PushButton("访问网站"), PushButton("访问网站"),
@@ -44,10 +51,10 @@ class AboutWidget(Widget):
self.vbox.addWidget(self.group_card) self.vbox.addWidget(self.group_card)
self.vbox.addStretch(1) self.vbox.addStretch(1)
self.group_card.addGroup("", "PySide6", self.url_list[0], self.button_list[0]) self.group_card.addGroup(":/images/3rd/qt.png", "PySide6", self.url_list[0], self.button_list[0])
self.group_card.addGroup("", "QFluentWidgets", self.url_list[1], self.button_list[1]) self.group_card.addGroup(":/images/3rd/qfluentwidgets", "QFluentWidgets", self.url_list[1], self.button_list[1])
self.group_card.addGroup("", "openpyxl", self.url_list[2], self.button_list[2]) self.group_card.addGroup(FluentIcon.LAYOUT, "openpyxl", self.url_list[2], self.button_list[2])
self.group_card.addGroup("", "python-docx", self.url_list[3], self.button_list[3]) self.group_card.addGroup(FluentIcon.LAYOUT, "python-docx", self.url_list[3], self.button_list[3])
self.version_card.clicked.connect( self.version_card.clicked.connect(
lambda: QDesktopServices.openUrl("https://cantyonion.site/git/cantyonion/DefenseTopicGenerator") lambda: QDesktopServices.openUrl("https://cantyonion.site/git/cantyonion/DefenseTopicGenerator")

View File

@@ -4,13 +4,14 @@ from typing import Callable, Literal
from PySide6.QtCore import Qt, Signal, QThread from PySide6.QtCore import Qt, Signal, QThread
from PySide6.QtWidgets import QVBoxLayout, QFileDialog, QHBoxLayout from PySide6.QtWidgets import QVBoxLayout, QFileDialog, QHBoxLayout
from qfluentwidgets import GroupHeaderCardWidget, FluentIcon, PushButton, LineEdit, IconWidget, InfoBarIcon, BodyLabel, \ from qfluentwidgets import GroupHeaderCardWidget, FluentIcon, PushButton, LineEdit, IconWidget, BodyLabel, \
PrimaryPushButton, SwitchButton PrimaryPushButton, SwitchButton
from module import LOGLEVEL from module import LOGLEVEL
from module.worker import ARGWorker from module.worker import ARGWorker
from ui.components.infobar import ProgressInfoBar from ui.components.infobar import ProgressInfoBar
from ui.components.widget import Widget from ui.components.widget import Widget
from ui import MAIN_THEME_COLOR
class InputSettingCard(GroupHeaderCardWidget): class InputSettingCard(GroupHeaderCardWidget):
@@ -56,12 +57,13 @@ class OutputSettingCard(GroupHeaderCardWidget):
self.autoOpenSwitch.setChecked(True) self.autoOpenSwitch.setChecked(True)
self.bottomLayout = QHBoxLayout() self.bottomLayout = QHBoxLayout()
self.hintIcon = IconWidget(InfoBarIcon.INFORMATION) self.hintIcon = IconWidget(FluentIcon.INFO.icon(color=MAIN_THEME_COLOR))
self.hintLabel = BodyLabel("点击开始按钮以开始生成 👉") self.hintLabel = BodyLabel("点击开始按钮以开始生成 👉")
self.startButton.setEnabled(False) self.startButton.setEnabled(False)
# 设置底部工具栏布局 # 设置底部工具栏布局
self.hintIcon.setFixedSize(16, 16) self.hintIcon.setFixedSize(16, 16)
self.hintIcon.autoFillBackground()
self.bottomLayout.setSpacing(10) self.bottomLayout.setSpacing(10)
self.bottomLayout.setContentsMargins(24, 15, 24, 20) self.bottomLayout.setContentsMargins(24, 15, 24, 20)
self.bottomLayout.addWidget(self.hintIcon, 0, Qt.AlignLeft) self.bottomLayout.addWidget(self.hintIcon, 0, Qt.AlignLeft)

View File

@@ -3,12 +3,13 @@ from typing import Literal, Callable
from PySide6.QtCore import Qt, Signal, QThread from PySide6.QtCore import Qt, Signal, QThread
from PySide6.QtWidgets import QHBoxLayout, QVBoxLayout, QFileDialog from PySide6.QtWidgets import QHBoxLayout, QVBoxLayout, QFileDialog
from qfluentwidgets import GroupHeaderCardWidget, PushButton, IconWidget, InfoBarIcon, \ from qfluentwidgets import GroupHeaderCardWidget, PushButton, IconWidget, BodyLabel, PrimaryPushButton, FluentIcon, \
BodyLabel, PrimaryPushButton, FluentIcon, LineEdit LineEdit
from module.worker import DTGWorker from module.worker import DTGWorker
from ui.components.infobar import ProgressInfoBar from ui.components.infobar import ProgressInfoBar
from ui.components.widget import Widget from ui.components.widget import Widget
from ui import MAIN_THEME_COLOR
class InitSettingCard(GroupHeaderCardWidget): class InitSettingCard(GroupHeaderCardWidget):
@@ -61,7 +62,7 @@ class ExportSettingsCard(GroupHeaderCardWidget):
self.exportFileNameLineEdit = LineEdit() self.exportFileNameLineEdit = LineEdit()
self.startButton = PrimaryPushButton(FluentIcon.PLAY_SOLID, "开始") self.startButton = PrimaryPushButton(FluentIcon.PLAY_SOLID, "开始")
self.hintIcon = IconWidget(InfoBarIcon.INFORMATION) self.hintIcon = IconWidget(FluentIcon.INFO.icon(color=MAIN_THEME_COLOR))
self.hintLabel = BodyLabel("点击开始按钮以开始生成 👉") self.hintLabel = BodyLabel("点击开始按钮以开始生成 👉")
self.chooseExportDirectoryButton.setFixedWidth(120) self.chooseExportDirectoryButton.setFixedWidth(120)
self.startButton.setFixedWidth(120) self.startButton.setFixedWidth(120)

6
ui/pyui/picker_ui.py Normal file
View File

@@ -0,0 +1,6 @@
from ui.components.widget import Widget
class PickerWidget(Widget):
def __init__(self, key: str, parent=None):
super().__init__(key, parent)

10
utils/hook.py Normal file
View File

@@ -0,0 +1,10 @@
from datetime import datetime
def gen_build_time():
with open('build_info.py', 'w', encoding='utf-8') as f:
f.write(f"# Auto-generated build info\n")
f.write(f"BUILD_TIME = '{datetime.now().isoformat(sep=' ', timespec='seconds')}'\n")
gen_build_time()