diff --git a/Image/login.svg b/Image/login.svg
new file mode 100644
index 0000000..ccae57b
--- /dev/null
+++ b/Image/login.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Image/logout.svg b/Image/logout.svg
new file mode 100644
index 0000000..1346842
--- /dev/null
+++ b/Image/logout.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Image/title_ico.png b/Image/title_ico.png
new file mode 100644
index 0000000..4d1031c
Binary files /dev/null and b/Image/title_ico.png differ
diff --git a/TEST3.py b/TEST3.py
new file mode 100644
index 0000000..7884bb6
--- /dev/null
+++ b/TEST3.py
@@ -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())
diff --git a/test.py b/test.py
index 024e4e3..af8fc28 100644
--- a/test.py
+++ b/test.py
@@ -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())
diff --git a/test2.py b/test2.py
new file mode 100644
index 0000000..01ec96e
--- /dev/null
+++ b/test2.py
@@ -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())
diff --git a/test5.py b/test5.py
new file mode 100644
index 0000000..49baf23
--- /dev/null
+++ b/test5.py
@@ -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())
diff --git a/untitled.ui b/untitled.ui
index 84cdc63..2276c30 100644
--- a/untitled.ui
+++ b/untitled.ui
@@ -1020,6 +1020,31 @@ background-color:#1cb052;
+
+
+
+ 84
+ 120
+ 101
+ 51
+
+
+
+ * {
+ 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 "楷体";
+border: 1px solid #dcdfe6;
+border-radius: 10px;
+}
+
+
+
+ PushButton
+
+