update 拟增加点位

This commit is contained in:
FrankCV2048
2024-10-16 23:18:25 +08:00
parent b88e1937ec
commit f037fa4fc3
8 changed files with 318 additions and 42 deletions

1
Image/login.svg Normal file
View File

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1729089862313" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5514" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M960.853333 903.816533a463.633067 463.633067 0 0 0-11.264-39.185066c-1.536-4.539733-3.413333-8.942933-5.051733-13.448534a484.078933 484.078933 0 0 0-9.557333-24.4736c-2.2528-5.188267-4.881067-10.274133-7.338667-15.394133-3.413333-7.099733-6.8608-14.165333-10.6496-21.0944-2.901333-5.3248-6.075733-10.513067-9.181867-15.701333-2.423467-4.061867-4.573867-8.226133-7.133866-12.219734-1.604267-2.4576-3.413333-4.778667-5.0176-7.202133-1.501867-2.218667-2.730667-4.608-4.266667-6.792533-0.4096-0.6144-1.058133-0.887467-1.501867-1.4336a461.482667 461.482667 0 0 0-90.385066-96.768c-13.5168-10.786133-27.7504-20.48-42.257067-29.5936-0.477867-0.341333-0.7168-0.8192-1.194667-1.1264-3.6864-2.286933-7.509333-4.3008-11.264-6.485334-4.266667-2.491733-8.4992-5.051733-12.868266-7.441066-6.826667-3.6864-13.789867-7.099733-20.753067-10.478934-3.618133-1.7408-7.202133-3.618133-10.8544-5.290666a449.194667 449.194667 0 0 0-31.607467-12.731734c-0.7168-0.273067-1.365333-0.6144-2.082133-0.8192-3.140267-1.1264-6.417067-1.911467-9.557333-2.935466-4.164267-1.399467-8.328533-2.833067-12.561067-4.096a259.9936 259.9936 0 0 0 129.194667-225.450667 260.061867 260.061867 0 0 0-76.629334-185.002667 259.9936 259.9936 0 0 0-185.002666-76.629333H512h-0.034133a259.857067 259.857067 0 0 0-185.002667 76.629333 259.925333 259.925333 0 0 0-76.629333 185.002667 259.584 259.584 0 0 0 76.629333 185.002667c15.906133 15.940267 33.655467 29.2864 52.565333 40.448-4.266667 1.262933-8.430933 2.730667-12.663466 4.096-3.140267 1.058133-6.3488 1.8432-9.489067 2.935466-0.7168 0.238933-1.365333 0.580267-2.048 0.8192-10.683733 3.822933-21.265067 8.0896-31.675733 12.765867-3.584 1.604267-7.0656 3.4816-10.615467 5.154133-7.099733 3.413333-14.165333 6.826667-21.0944 10.615467-4.266667 2.321067-8.3968 4.8128-12.561067 7.2704-3.822933 2.218667-7.748267 4.266667-11.502933 6.621867-0.512 0.3072-0.750933 0.8192-1.2288 1.160533-14.506667 9.147733-28.706133 18.807467-42.222933 29.559467a459.6736 459.6736 0 0 0-90.385067 96.768c-0.443733 0.546133-1.092267 0.8192-1.501867 1.4336-1.536 2.184533-2.7648 4.573867-4.266666 6.792533-1.604267 2.423467-3.447467 4.744533-5.0176 7.202133-2.56 3.9936-4.7104 8.157867-7.133867 12.219734-3.106133 5.188267-6.280533 10.376533-9.181867 15.701333-3.7888 6.929067-7.202133 13.994667-10.6496 21.0944-2.4576 5.12-5.051733 10.205867-7.338666 15.394133-3.515733 8.021333-6.519467 16.247467-9.557334 24.4736-1.672533 4.5056-3.549867 8.9088-5.051733 13.448534-4.3008 12.868267-8.0896 25.941333-11.264 39.185066-3.072 12.970667 2.594133 25.770667 13.073067 32.802134a31.3344 31.3344 0 0 0 9.966933 4.608 30.9248 30.9248 0 0 0 34.030933-15.2576 30.446933 30.446933 0 0 0 3.345067-7.7824c2.833067-11.844267 6.178133-23.483733 10.0352-34.9184 0.6144-1.8432 1.399467-3.549867 2.013867-5.358934 3.447467-9.762133 7.133867-19.456 11.332266-28.945066 0.512-1.160533 1.1264-2.2528 1.6384-3.447467 4.7104-10.308267 9.728-20.48 15.291734-30.344533l0.068266-0.1024a402.773333 402.773333 0 0 1 19.694934-31.4368l0.136533-0.375467a397.4144 397.4144 0 0 1 116.599467-111.2064c0.136533-0.1024 0.3072-0.068267 0.443733-0.170667a397.824 397.824 0 0 1 94.993067-42.973866c2.7648-0.8192 5.495467-1.7408 8.2944-2.491734 5.7344-1.604267 11.5712-3.003733 17.373866-4.334933a367.8208 367.8208 0 0 1 47.342934-7.953067c3.8912-0.443733 7.7824-0.9216 11.6736-1.2288 10.410667-0.785067 20.8896-1.3312 31.505066-1.3312s21.060267 0.546133 31.505067 1.3312c3.8912 0.3072 7.816533 0.785067 11.707733 1.2288a361.3696 361.3696 0 0 1 47.240534 7.953067c5.870933 1.3312 11.707733 2.730667 17.5104 4.334933 2.696533 0.750933 5.358933 1.6384 8.021333 2.4576 33.348267 10.103467 65.365333 24.405333 95.197867 43.008 0.136533 0.1024 0.3072 0.068267 0.443733 0.170667a396.151467 396.151467 0 0 1 116.599467 111.2064c0.1024 0.136533 0.1024 0.273067 0.170666 0.375467 13.687467 19.7632 25.3952 40.5504 35.191467 62.1568l1.467733 3.037866c4.3008 9.659733 8.055467 19.592533 11.605334 29.5936 0.546133 1.604267 1.2288 3.106133 1.774933 4.7104 3.822933 11.4688 7.236267 23.176533 10.0352 35.0208a31.061333 31.061333 0 0 0 60.450133-14.336z m-249.275733-560.2304A199.850667 199.850667 0 0 1 512 543.197867a199.850667 199.850667 0 0 1-199.5776-199.611734A199.816533 199.816533 0 0 1 512 144.008533a199.816533 199.816533 0 0 1 199.5776 199.5776z" fill="#8E919C" p-id="5515"></path></svg>

After

Width:  |  Height:  |  Size: 4.6 KiB

1
Image/logout.svg Normal file
View File

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1729089581638" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4087" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M874.666667 855.744a19.093333 19.093333 0 0 1-19.136 18.922667H168.469333A19.2 19.2 0 0 1 149.333333 855.530667V168.469333A19.2 19.2 0 0 1 168.469333 149.333333h687.061334c10.581333 0 19.136 8.533333 19.136 18.922667V320h42.666666V168.256A61.717333 61.717333 0 0 0 855.530667 106.666667H168.469333A61.866667 61.866667 0 0 0 106.666667 168.469333v687.061334A61.866667 61.866667 0 0 0 168.469333 917.333333h687.061334A61.76 61.76 0 0 0 917.333333 855.744V704h-42.666666v151.744zM851.84 533.333333l-131.797333 131.754667a21.141333 21.141333 0 0 0 0.213333 29.973333 21.141333 21.141333 0 0 0 29.973333 0.192l165.589334-165.589333a20.821333 20.821333 0 0 0 6.122666-14.976 21.44 21.44 0 0 0-6.314666-14.997333l-168.533334-168.533334a21.141333 21.141333 0 0 0-29.952-0.213333 21.141333 21.141333 0 0 0 0.213334 29.973333L847.296 490.666667H469.333333v42.666666h382.506667z" fill="#8E919C" p-id="4088"></path></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
Image/title_ico.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

90
TEST3.py Normal file
View File

@ -0,0 +1,90 @@
from PySide6.QtWidgets import QApplication, QPushButton, QMainWindow
from PySide6.QtGui import QPainter, QRadialGradient, QColor, QFont
from PySide6.QtCore import Qt, QRectF, QPropertyAnimation, QEasingCurve
import sys
class GradientButton(QPushButton):
def __init__(self, text, parent=None):
super().__init__(text, parent)
self.setFlat(True)
self.setFont(QFont("Arial", 14, QFont.Bold))
self.setMouseTracking(True)
self.hover = False
self.animation = QPropertyAnimation(self, b"geometry")
self.animation.setDuration(100)
self.animation.setEasingCurve(QEasingCurve.OutQuad)
def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
rect = self.rect()
gradient = QRadialGradient(rect.width()/2,rect.top(), rect.width())
gradient.setColorAt(0, QColor(0, 0, 0))
gradient.setColorAt(1, QColor(255, 255, 255))
if self.hover:
gradient.setColorAt(0, QColor(30, 30, 30))
gradient.setColorAt(1, QColor(220, 220, 220))
brush = gradient
painter.setBrush(brush)
painter.setPen(Qt.NoPen)
radius = 10
painter.drawRoundedRect(QRectF(rect), radius, radius)
painter.setPen(QColor(0, 0, 0) if not self.hover else QColor(50, 50, 50))
painter.drawText(rect, Qt.AlignCenter, self.text())
def enterEvent(self, event):
self.hover = True
self.update()
super().enterEvent(event)
def leaveEvent(self, event):
self.hover = False
self.update()
super().leaveEvent(event)
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
# 开始缩放动画(缩小)
geom = self.geometry()
new_geom = geom.adjusted(5, 5, -5, -5)
self.animation.stop()
self.animation.setStartValue(geom)
self.animation.setEndValue(new_geom)
self.animation.start()
super().mousePressEvent(event)
def mouseReleaseEvent(self, event):
if event.button() == Qt.LeftButton:
# 恢复原始大小
geom = self.geometry()
new_geom = geom.adjusted(-5, -5, 5, 5)
self.animation.stop()
self.animation.setStartValue(geom)
self.animation.setEndValue(new_geom)
self.animation.start()
super().mouseReleaseEvent(event)
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("带动画的渐变按钮示例")
self.setFixedSize(400, 300)
self.button = GradientButton("点击我", self)
self.button.setGeometry(150, 130, 100, 40)
self.button.clicked.connect(self.on_button_click)
def on_button_click(self):
print("按钮被点击了!")
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec())

127
test.py
View File

@ -1,49 +1,92 @@
from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout, QSlider, QLabel, QPushButton
from PySide6.QtCore import Qt #211
from PySide6.QtWidgets import QApplication, QPushButton, QMainWindow
from PySide6.QtCore import QPropertyAnimation, QPoint, QParallelAnimationGroup, QEasingCurve, Property
from PySide6.QtGui import QColor, QPainter, QBrush
from PySide6.QtCore import Qt
import sys
class SliderExample(QWidget):
class RippleButton(QPushButton):
def __init__(self, text, parent=None):
super().__init__(text, parent)
self._ripple_radius = 0
self._ripple_opacity = 1.0
self.ripple_position = QPoint()
self.animation_group = QParallelAnimationGroup(self) # 设置父对象
self.setStyleSheet("background-color: #3498db; color: white; border-radius: 5px; padding: 10px;")
self.setAttribute(Qt.WA_StaticContents)
def paintEvent(self, event):
super().paintEvent(event)
if self._ripple_radius > 0:
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
color = QColor(255, 255, 255)
color.setAlphaF(self._ripple_opacity)
painter.setBrush(QBrush(color))
painter.setPen(Qt.NoPen)
painter.drawEllipse(self.ripple_position, self._ripple_radius, self._ripple_radius)
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
self.ripple_position = event.pos()
self.startRippleEffect()
super().mousePressEvent(event)
def startRippleEffect(self):
# 取消之前的动画
self.animation_group.stop()
self.animation_group.clear()
# 创建半径动画
radius_animation = QPropertyAnimation(self, b"rippleRadius")
radius_animation.setDuration(600)
radius_animation.setStartValue(0)
# 计算最大半径,确保覆盖按钮
max_radius = max(self.width(), self.height()) * 1.5
radius_animation.setEndValue(max_radius)
radius_animation.setEasingCurve(QEasingCurve.OutQuad)
# 创建透明度动画
opacity_animation = QPropertyAnimation(self, b"rippleOpacity")
opacity_animation.setDuration(600)
opacity_animation.setStartValue(0.5) # 初始透明度可以调整
opacity_animation.setEndValue(0.0)
opacity_animation.setEasingCurve(QEasingCurve.OutQuad)
# 将动画添加到动画组
self.animation_group.addAnimation(radius_animation)
self.animation_group.addAnimation(opacity_animation)
self.animation_group.start()
# 使用 @Property 装饰器正确定义属性
def getRippleRadius(self):
return self._ripple_radius
def setRippleRadius(self, radius):
self._ripple_radius = radius
self.update()
rippleRadius = Property(float, getRippleRadius, setRippleRadius)
def getRippleOpacity(self):
return self._ripple_opacity
def setRippleOpacity(self, opacity):
self._ripple_opacity = opacity
self.update()
rippleOpacity = Property(float, getRippleOpacity, setRippleOpacity)
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("水滴扩散按钮示例")
self.setFixedSize(400, 300)
self.init_ui()
def init_ui(self):
# 创建一个垂直布局
layout = QVBoxLayout()
# 创建一个标签来显示滑块的值
self.label = QLabel("当前值: 0", self)
layout.addWidget(self.label)
# 创建一个滑块
self.slider = QSlider(Qt.Horizontal, self)
self.slider.setMinimum(0)
self.slider.setMaximum(100)
self.slider.setValue(0) # 初始值设为0
self.slider.setTickPosition(QSlider.TicksBelow)
self.slider.setTickInterval(10)
layout.addWidget(self.slider)
# 创建一个按钮来获取滑块的当前值
self.button = QPushButton("获取滑块值", self)
self.button.clicked.connect(self.show_slider_value)
layout.addWidget(self.button)
# 设置窗口布局
self.setLayout(layout)
self.setWindowTitle('QSlider 示例')
def show_slider_value(self):
# 直接获取滑块的当前值并更新标签
value = self.slider.value()
print(f"滑块的值是: {value}") # 添加打印以调试
self.label.setText(f"当前值: {value}")
self.button = RippleButton("点击我", self)
self.button.setGeometry(150, 130, 100, 40)
if __name__ == "__main__":
app = QApplication([])
window = SliderExample()
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()
sys.exit(app.exec())

76
test2.py Normal file
View File

@ -0,0 +1,76 @@
from PySide6.QtWidgets import QApplication, QPushButton, QMainWindow
from PySide6.QtGui import QPainter, QLinearGradient, QColor, QFont
from PySide6.QtCore import Qt, QRectF
import sys
class GradientButton(QPushButton):
def __init__(self, text, parent=None):
super().__init__(text, parent)
# 设置按钮无边框
self.setFlat(True)
# 设置按钮文本对齐方式
# 设置按钮字体
self.setFont(QFont("Arial", 14, QFont.Bold))
# 启用鼠标追踪以便在悬停时重绘
self.setMouseTracking(True)
# 当前是否悬停
self.hover = False
def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
# 获取按钮的矩形区域
rect = self.rect()
# 创建线性渐变,从中心线向上下渐变
gradient = QLinearGradient(rect.center().x(), rect.top(), rect.center().x(), rect.bottom())
gradient.setColorAt(0, QColor(225,225,225))
gradient.setColorAt(0.5, QColor('#1A1F38'))
gradient.setColorAt(1, QColor(225,225,225))
brush = gradient
painter.setBrush(brush)
painter.setPen(Qt.NoPen)
# 绘制圆角矩形作为按钮背景
radius = 2 # 圆角半径
painter.drawRoundedRect(QRectF(rect), radius, radius)
# 绘制按钮文本
painter.setPen(QColor('#E8E9EB')) # 设置字体为白色
painter.drawText(rect, Qt.AlignCenter, self.text())
def enterEvent(self, event):
self.hover = True
self.update() # 触发重绘
super().enterEvent(event)
def leaveEvent(self, event):
self.hover = False
self.update() # 触发重绘
super().leaveEvent(event)
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("中心线性渐变按钮示例")
self.setFixedSize(400, 300)
# 创建自定义渐变按钮
self.button = GradientButton("点击我", self)
self.button.setGeometry(100, 130, 100, 40)
# 连接按钮点击事件
self.button.clicked.connect(self.on_button_click)
def on_button_click(self):
print("按钮被点击了!")
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec())

40
test5.py Normal file
View File

@ -0,0 +1,40 @@
from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton
import sys
app = QApplication(sys.argv)
window = QWidget()
layout = QVBoxLayout()
# 创建按钮
button = QPushButton("Button")
# 使用 QSS 设置按钮样式
window.setStyleSheet("""
QPushButton {
background-color: #4CAF50; /* 按钮背景色 */
color: white; /* 按钮文本颜色 */
padding: 10px; /* 按钮内边距 */
border: none; /* 移除所有默认边框 */
border-right: 20px solid white; /* 仅设置右边的边框 */
background-color: qlineargradient(x1: 0.5, y1: 0, x2: 0.5, y2: 1, stop: 0 #4CAF50, stop: 0.5 rgba(0, 235, 0, 0), stop: 1 #4CAF50);
border-width: 2px; /* 边框宽度 */
border-radius: 5px; /* 按钮圆角 */
}
QPushButton:hover {
background-color: #45a049; /* 悬停时背景色 */
}
""")
##
# border-color:qradialgradient(cx: 0.5, cy: 0.5
# , radius: 0.8, fx:0.5 ,fy:0.5,
# stop: 0 rgba(255, 255, 255, 255),
# stop: 1 rgba(19, 36, 69, 255));
layout.addWidget(button)
window.setLayout(layout)
window.show()
sys.exit(app.exec())

View File

@ -1020,6 +1020,31 @@ background-color:#1cb052;
<iconset theme="QIcon::ThemeIcon::SystemReboot"/>
</property>
</widget>
<widget class="QPushButton" name="pushButton_3">
<property name="geometry">
<rect>
<x>84</x>
<y>120</y>
<width>101</width>
<height>51</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">* {
background: qradialgradient(cx: 0.5, cy: 0.1
, radius: 0.8, fx:0.5 ,fy:0,
stop: 0 rgba(255,255,255, 255),
stop: 1 rgba(33, 150, 243, 255));
font: 9pt &quot;楷体&quot;;
border: 1px solid #dcdfe6;
border-radius: 10px;
}
</string>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
</widget>
</widget>
<widget class="QWidget" name="tab_5">