update:UI部分完成

This commit is contained in:
2025-07-03 21:32:44 +08:00
parent 4b15f0fe70
commit 39e29689ec
16 changed files with 361 additions and 88 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 849 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 KiB

After

Width:  |  Height:  |  Size: 571 KiB

BIN
IMG/BG/bg3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

BIN
IMG/BG/bg4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
IMG/BG/menubg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 KiB

BIN
IMG/BTH/exit.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
IMG/BTH/start_install.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -17,7 +17,7 @@ from PySide6.QtGui import (QAction, QBrush, QColor, QConicalGradient,
QPainter, QPalette, QPixmap, QRadialGradient,
QTransform)
from PySide6.QtWidgets import (QApplication, QLabel, QMainWindow, QMenu,
QMenuBar, QSizePolicy, QWidget)
QMenuBar, QPushButton, QSizePolicy, QWidget)
class Ui_MainWindows(object):
def setupUi(self, MainWindows):
@@ -40,37 +40,81 @@ class Ui_MainWindows(object):
self.centralwidget = QWidget(MainWindows)
self.centralwidget.setObjectName(u"centralwidget")
self.centralwidget.setAutoFillBackground(True)
self.MainBg = QLabel(self.centralwidget)
self.MainBg.setObjectName(u"MainBg")
self.MainBg.setGeometry(QRect(0, 0, 1031, 561))
self.MainBg.setPixmap(QPixmap(u"IMG/BG/bg2.jpg"))
self.MainBg.setScaledContents(True)
self.loadbg = QLabel(self.centralwidget)
self.loadbg.setObjectName(u"loadbg")
self.loadbg.setGeometry(QRect(0, 0, 1031, 561))
self.loadbg.setPixmap(QPixmap(u"IMG/BG/bg2.jpg"))
self.loadbg.setScaledContents(True)
self.vol1bg = QLabel(self.centralwidget)
self.vol1bg.setObjectName(u"vol1bg")
self.vol1bg.setGeometry(QRect(0, 250, 93, 64))
self.vol1bg.setGeometry(QRect(0, 120, 93, 64))
self.vol1bg.setPixmap(QPixmap(u"IMG/LOGO/vo01_logo.png"))
self.vol1bg.setScaledContents(True)
self.vol2bg = QLabel(self.centralwidget)
self.vol2bg.setObjectName(u"vol2bg")
self.vol2bg.setGeometry(QRect(0, 310, 93, 64))
self.vol2bg.setGeometry(QRect(0, 180, 93, 64))
self.vol2bg.setPixmap(QPixmap(u"IMG/LOGO/vo02_logo.png"))
self.vol2bg.setScaledContents(True)
self.vol3bg = QLabel(self.centralwidget)
self.vol3bg.setObjectName(u"vol3bg")
self.vol3bg.setGeometry(QRect(0, 370, 93, 64))
self.vol3bg.setGeometry(QRect(0, 240, 93, 64))
self.vol3bg.setPixmap(QPixmap(u"IMG/LOGO/vo03_logo.png"))
self.vol3bg.setScaledContents(True)
self.vol4bg = QLabel(self.centralwidget)
self.vol4bg.setObjectName(u"vol4bg")
self.vol4bg.setGeometry(QRect(0, 430, 93, 64))
self.vol4bg.setGeometry(QRect(0, 300, 93, 64))
self.vol4bg.setPixmap(QPixmap(u"IMG/LOGO/vo04_logo.png"))
self.vol4bg.setScaledContents(True)
self.afterbg = QLabel(self.centralwidget)
self.afterbg.setObjectName(u"afterbg")
self.afterbg.setGeometry(QRect(0, 490, 93, 64))
self.afterbg.setGeometry(QRect(0, 360, 93, 64))
self.afterbg.setPixmap(QPixmap(u"IMG/LOGO/voaf_logo.png"))
self.afterbg.setScaledContents(True)
self.Mainbg = QLabel(self.centralwidget)
self.Mainbg.setObjectName(u"Mainbg")
self.Mainbg.setGeometry(QRect(0, 0, 1031, 561))
self.Mainbg.setPixmap(QPixmap(u"IMG/BG/bg3.jpg"))
self.Mainbg.setScaledContents(True)
self.pushButton = QPushButton(self.centralwidget)
self.pushButton.setObjectName(u"pushButton")
self.pushButton.setEnabled(True)
self.pushButton.setGeometry(QRect(780, 250, 191, 91))
self.pushButton.setAutoFillBackground(False)
icon = QIcon()
icon.addFile(u"IMG/BTH/start_install.bmp", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.pushButton.setIcon(icon)
self.pushButton.setIconSize(QSize(189, 110))
self.pushButton.setCheckable(False)
self.pushButton.setAutoRepeat(False)
self.pushButton.setAutoDefault(False)
self.pushButton.setFlat(True)
self.pushButton_2 = QPushButton(self.centralwidget)
self.pushButton_2.setObjectName(u"pushButton_2")
self.pushButton_2.setEnabled(True)
self.pushButton_2.setGeometry(QRect(780, 340, 191, 91))
self.pushButton_2.setAutoFillBackground(False)
icon1 = QIcon()
icon1.addFile(u"IMG/BTH/exit.bmp", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
self.pushButton_2.setIcon(icon1)
self.pushButton_2.setIconSize(QSize(189, 110))
self.pushButton_2.setCheckable(False)
self.pushButton_2.setFlat(True)
self.menubg = QLabel(self.centralwidget)
self.menubg.setObjectName(u"menubg")
self.menubg.setGeometry(QRect(710, 0, 321, 561))
self.menubg.setPixmap(QPixmap(u"IMG/BG/menubg.jpg"))
self.menubg.setScaledContents(True)
MainWindows.setCentralWidget(self.centralwidget)
self.loadbg.raise_()
self.vol1bg.raise_()
self.vol2bg.raise_()
self.vol3bg.raise_()
self.vol4bg.raise_()
self.afterbg.raise_()
self.Mainbg.raise_()
self.menubg.raise_()
self.pushButton.raise_()
self.pushButton_2.raise_()
self.menubar = QMenuBar(MainWindows)
self.menubar.setObjectName(u"menubar")
self.menubar.setGeometry(QRect(0, 0, 1024, 21))
@@ -93,12 +137,19 @@ class Ui_MainWindows(object):
def retranslateUi(self, MainWindows):
MainWindows.setWindowTitle(QCoreApplication.translate("MainWindows", u" UI Test", None))
self.action_2.setText(QCoreApplication.translate("MainWindows", u"update - sd", None))
self.MainBg.setText("")
self.loadbg.setText("")
self.vol1bg.setText("")
self.vol2bg.setText("")
self.vol3bg.setText("")
self.vol4bg.setText("")
self.afterbg.setText("")
self.Mainbg.setText("")
#if QT_CONFIG(accessibility)
self.pushButton.setAccessibleDescription("")
#endif // QT_CONFIG(accessibility)
self.pushButton.setText("")
self.pushButton_2.setText("")
self.menubg.setText("")
self.menu.setTitle(QCoreApplication.translate("MainWindows", u"\u8bbe\u7f6e", None))
self.menu_2.setTitle(QCoreApplication.translate("MainWindows", u"\u5173\u4e8e", None))
# retranslateUi

View File

@@ -1,72 +1,167 @@
from PySide6.QtCore import (QPropertyAnimation, QSequentialAnimationGroup,
QParallelAnimationGroup, QPoint, QEasingCurve)
from PySide6.QtCore import (QPropertyAnimation, QParallelAnimationGroup,
QPoint, QEasingCurve, QTimer)
from PySide6.QtWidgets import QGraphicsOpacityEffect
class LogoAnimations:
class MultiStageAnimations:
def __init__(self, ui):
self.ui = ui
self.logos = [
ui.vol1bg, ui.vol2bg, ui.vol3bg,
ui.vol4bg, ui.afterbg
# 获取画布尺寸
self.canvas_width = ui.centralwidget.width()
self.canvas_height = ui.centralwidget.height()
# 动画时序配置
self.animation_config = {
"logo": {
"delay_after": 800 # Logo动画完成后等待300ms
},
"mainbg": {
"delay_after": 200 # 主背景淡入完成后等待200ms
}
}
# 第一阶段Logo动画配置
self.logo_widgets = [
{"widget": ui.vol1bg, "delay": 0, "duration": 500, "end_pos": QPoint(0, 120)},
{"widget": ui.vol2bg, "delay": 80, "duration": 500, "end_pos": QPoint(0, 180)},
{"widget": ui.vol3bg, "delay": 160, "duration": 500, "end_pos": QPoint(0, 240)},
{"widget": ui.vol4bg, "delay": 240, "duration": 500, "end_pos": QPoint(0, 300)},
{"widget": ui.afterbg, "delay": 320, "duration": 500, "end_pos": QPoint(0, 360)}
]
self.animation_group = None
# 第二阶段:菜单元素
self.menu_widgets = [
{"widget": ui.menubg, "end_pos": QPoint(710, 0), "duration": 600},
{"widget": ui.pushButton, "end_pos": QPoint(780, 250), "duration": 600},
{"widget": ui.pushButton_2, "end_pos": QPoint(780, 340), "duration": 600}
]
self.animations = []
self.timers = []
def initialize(self):
"""初始化所有logo的状态透明且位于屏幕外"""
for logo in self.logos:
# 保存原始位置
logo.original_pos = logo.pos()
# 设置透明度效果
opacity_effect = QGraphicsOpacityEffect(logo)
logo.setGraphicsEffect(opacity_effect)
opacity_effect.setOpacity(0)
# 移动到屏幕左侧外
logo.move(-logo.width(), logo.y())
"""初始化所有组件状态"""
# 设置Mainbg初始状态
effect = QGraphicsOpacityEffect(self.ui.Mainbg)
effect.setOpacity(0)
self.ui.Mainbg.setGraphicsEffect(effect)
# 初始化Logo位置移到左侧外
for item in self.logo_widgets:
widget = item["widget"]
effect = QGraphicsOpacityEffect(widget)
effect.setOpacity(0)
widget.setGraphicsEffect(effect)
widget.move(-widget.width(), item["end_pos"].y())
widget.show()
# 初始化菜单元素(底部外)
for item in self.menu_widgets:
widget = item["widget"]
effect = QGraphicsOpacityEffect(widget)
effect.setOpacity(0)
widget.setGraphicsEffect(effect)
widget.move(widget.x(), self.canvas_height + 100)
widget.show()
def create_animation_sequence(self):
"""创建顺序动画序列"""
self.animation_group = QSequentialAnimationGroup()
def start_logo_animations(self):
"""启动Logo动画序列"""
for item in self.logo_widgets:
timer = QTimer()
timer.setSingleShot(True)
timer.timeout.connect(
lambda w=item["widget"], d=item["duration"], pos=item["end_pos"]:
self.animate_logo(w, pos, d)
)
timer.start(item["delay"])
self.timers.append(timer)
def animate_logo(self, widget, end_pos, duration):
"""执行单个Logo动画"""
anim_group = QParallelAnimationGroup()
# 为每个logo创建动画延迟递增
delays = [0, 50, 100, 150, 200] # 每个动画的延迟时间(ms)
# 位置动画
pos_anim = QPropertyAnimation(widget, b"pos")
pos_anim.setDuration(duration)
pos_anim.setStartValue(QPoint(-widget.width(), end_pos.y()))
pos_anim.setEndValue(end_pos)
pos_anim.setEasingCurve(QEasingCurve.OutBack)
for i, logo in enumerate(self.logos):
# 创建并行动画组(位置+透明度)
parallel_group = QParallelAnimationGroup()
# 透明度动画
opacity_anim = QPropertyAnimation(widget.graphicsEffect(), b"opacity")
opacity_anim.setDuration(duration)
opacity_anim.setStartValue(0)
opacity_anim.setEndValue(1)
anim_group.addAnimation(pos_anim)
anim_group.addAnimation(opacity_anim)
# 最后一个Logo动画完成后添加延迟
if widget == self.logo_widgets[-1]["widget"]:
anim_group.finished.connect(
lambda: QTimer.singleShot(
self.animation_config["logo"]["delay_after"],
self.start_mainbg_animation
)
)
anim_group.start()
self.animations.append(anim_group)
def start_mainbg_animation(self):
"""启动主背景淡入动画"""
main_anim = QPropertyAnimation(self.ui.Mainbg.graphicsEffect(), b"opacity")
main_anim.setDuration(800)
main_anim.setStartValue(0)
main_anim.setEndValue(1)
main_anim.finished.connect(self.start_menu_animations)
main_anim.start()
self.animations.append(main_anim)
def start_mainbg_animation(self):
"""启动主背景淡入动画(带延迟)"""
main_anim = QPropertyAnimation(self.ui.Mainbg.graphicsEffect(), b"opacity")
main_anim.setDuration(800)
main_anim.setStartValue(0)
main_anim.setEndValue(1)
main_anim.finished.connect(
lambda: QTimer.singleShot(
self.animation_config["mainbg"]["delay_after"],
self.start_menu_animations
)
)
main_anim.start()
self.animations.append(main_anim)
def start_menu_animations(self):
"""启动菜单动画(从下往上)"""
for item in self.menu_widgets:
anim_group = QParallelAnimationGroup()
# 位置动画(从左侧滑入
pos_anim = QPropertyAnimation(logo, b"pos")
pos_anim.setDuration(800)
pos_anim.setStartValue(QPoint(-logo.width(), logo.y()))
pos_anim.setEndValue(logo.original_pos)
# 位置动画(从下往上
pos_anim = QPropertyAnimation(item["widget"], b"pos")
pos_anim.setDuration(item["duration"])
pos_anim.setStartValue(QPoint(item["end_pos"].x(), self.canvas_height + 100))
pos_anim.setEndValue(item["end_pos"])
pos_anim.setEasingCurve(QEasingCurve.OutBack)
# 透明度动画(淡入)
opacity_anim = QPropertyAnimation(logo.graphicsEffect(), b"opacity")
opacity_anim.setDuration(800)
# 透明度动画
opacity_anim = QPropertyAnimation(item["widget"].graphicsEffect(), b"opacity")
opacity_anim.setDuration(item["duration"])
opacity_anim.setStartValue(0)
opacity_anim.setEndValue(1)
parallel_group.addAnimation(pos_anim)
parallel_group.addAnimation(opacity_anim)
# 添加延迟(使动画按顺序触发)
if delays[i] > 0:
delay_anim = QPropertyAnimation(logo, b"pos")
delay_anim.setDuration(delays[i])
self.animation_group.addAnimation(delay_anim)
self.animation_group.addAnimation(parallel_group)
return self.animation_group
anim_group.addAnimation(pos_anim)
anim_group.addAnimation(opacity_anim)
anim_group.start()
self.animations.append(anim_group)
def start_animations(self):
"""启动完整动画序列"""
self.clear_animations()
self.start_logo_animations()
def start_animation(self):
"""启动动画序列"""
self.initialize()
self.create_animation_sequence()
self.animation_group.start()
def stop_animation(self):
"""停止动画"""
if self.animation_group:
self.animation_group.stop()
def clear_animations(self):
"""清理所有动画资源"""
for timer in self.timers:
timer.stop()
for anim in self.animations:
anim.stop()
self.timers.clear()
self.animations.clear()

View File

@@ -56,7 +56,7 @@
<property name="autoFillBackground">
<bool>true</bool>
</property>
<widget class="QLabel" name="MainBg">
<widget class="QLabel" name="loadbg">
<property name="geometry">
<rect>
<x>0</x>
@@ -79,7 +79,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>250</y>
<y>120</y>
<width>93</width>
<height>64</height>
</rect>
@@ -98,7 +98,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>310</y>
<y>180</y>
<width>93</width>
<height>64</height>
</rect>
@@ -117,7 +117,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>370</y>
<y>240</y>
<width>93</width>
<height>64</height>
</rect>
@@ -136,7 +136,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>430</y>
<y>300</y>
<width>93</width>
<height>64</height>
</rect>
@@ -155,7 +155,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>490</y>
<y>360</y>
<width>93</width>
<height>64</height>
</rect>
@@ -170,6 +170,133 @@
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="Mainbg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1031</width>
<height>561</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>IMG/BG/bg3.jpg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="start_install_btn">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>780</x>
<y>250</y>
<width>191</width>
<height>91</height>
</rect>
</property>
<property name="accessibleDescription">
<string/>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff>IMG/BTH/start_install.bmp</normaloff>IMG/BTH/start_install.bmp</iconset>
</property>
<property name="iconSize">
<size>
<width>189</width>
<height>110</height>
</size>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="autoRepeat">
<bool>false</bool>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="exit_btn">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>780</x>
<y>340</y>
<width>191</width>
<height>91</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff>IMG/BTH/exit.bmp</normaloff>IMG/BTH/exit.bmp</iconset>
</property>
<property name="iconSize">
<size>
<width>189</width>
<height>110</height>
</size>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="menubg">
<property name="geometry">
<rect>
<x>710</x>
<y>0</y>
<width>321</width>
<height>561</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>IMG/BG/menubg.jpg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<zorder>loadbg</zorder>
<zorder>vol1bg</zorder>
<zorder>vol2bg</zorder>
<zorder>vol3bg</zorder>
<zorder>vol4bg</zorder>
<zorder>afterbg</zorder>
<zorder>Mainbg</zorder>
<zorder>menubg</zorder>
<zorder>start_install_btn</zorder>
<zorder>exit_btn</zorder>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">

View File

@@ -1,7 +1,5 @@
# main.py
import sys
from PySide6.QtWidgets import QApplication
from Ui_install import Ui_MainWindows
from main_window import MainWindow
def main():

View File

@@ -1,26 +1,28 @@
from PySide6.QtWidgets import QMainWindow
from Ui_install import Ui_MainWindows # 导入你的UI文件
from animations import LogoAnimations
from PySide6.QtCore import QTimer
from Ui_install import Ui_MainWindows
from animations import MultiStageAnimations
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
# 设置UI
# 先初始化UI
self.ui = Ui_MainWindows()
self.ui.setupUi(self)
# 初始化动画系统
self.logo_animations = LogoAnimations(self.ui)
# 然后初始化动画系统
self.animator = MultiStageAnimations(self.ui)
# 窗口显示时自动启动动画
self.showEvent = self.on_show_event
# 窗口显示前设置初始状态
self.animator.initialize()
def on_show_event(self, event):
"""窗口显示事件处理"""
self.logo_animations.start_animation()
super().showEvent(event)
# 窗口显示后延迟100ms启动动画
QTimer.singleShot(100, self.start_animations)
def start_animations(self):
self.animator.start_animations()
def closeEvent(self, event):
"""窗口关闭事件处理"""
self.logo_animations.stop_animation()
self.animator.clear_animations()
super().closeEvent(event)