41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
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())
|