initial fluent-widgets ui

This commit is contained in:
2025-08-14 18:45:16 +08:00
parent 746e83ab23
commit 4c66886257
1198 changed files with 805339 additions and 0 deletions

View File

@ -0,0 +1,35 @@
# coding:utf-8
import sys
from PySide6.QtCore import Qt
from PySide6.QtGui import QPainterPath, QPixmap
from PySide6.QtWidgets import QApplication, QWidget
from qfluentwidgets.components.widgets.acrylic_label import AcrylicBrush
class Demo(QWidget):
def __init__(self):
super().__init__()
self.resize(400, 400)
self.acrylicBrush = AcrylicBrush(self, 15)
path = QPainterPath()
path.addEllipse(0, 0, 400, 400)
self.acrylicBrush.setClipPath(path)
self.acrylicBrush.setImage(QPixmap('resource/shoko.png').scaled(
400, 400, Qt.KeepAspectRatio, Qt.SmoothTransformation))
def paintEvent(self, e):
self.acrylicBrush.paint()
super().paintEvent(e)
if __name__ == '__main__':
app = QApplication(sys.argv)
w = Demo()
w.show()
app.exec()

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

View File

@ -0,0 +1,39 @@
# coding:utf-8
import sys
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QApplication, QWidget, QCompleter, QVBoxLayout
from qfluentwidgets import ComboBox, setTheme, Theme, setThemeColor, EditableComboBox, setFont
from qfluentwidgets.components.material import AcrylicComboBox, AcrylicEditableComboBox
class Demo(QWidget):
def __init__(self):
super().__init__()
self.comboBox = AcrylicComboBox(self)
self.hBoxLayout = QVBoxLayout(self)
items = ['shoko 🥰', '西宫硝子', 'aiko', '柳井爱子']
self.comboBox.addItems(items)
self.comboBox.setCurrentIndex(0)
self.comboBox.currentTextChanged.connect(print)
# NOTE: Completer is only applicable to AcrylicEditableComboBox
# self.completer = QCompleter(items, self)
# self.comboBox.setCompleter(self.completer)
self.resize(300, 300)
self.hBoxLayout.addWidget(self.comboBox, 0, Qt.AlignmentFlag.AlignCenter)
self.setStyleSheet('Demo{background:white}')
# setTheme(Theme.DARK)
# setThemeColor('#0078d4')
# setFont(self.comboBox, 16)
if __name__ == '__main__':
app = QApplication(sys.argv)
w = Demo()
w.show()
app.exec()

View File

@ -0,0 +1,94 @@
# coding:utf-8
import sys
from PySide6.QtCore import Qt
from PySide6.QtGui import QFont
from PySide6.QtWidgets import QApplication, QWidget, QHBoxLayout, QVBoxLayout
from qfluentwidgets import (PushButton, Flyout, InfoBarIcon, setTheme, Theme, FlyoutView, FlyoutViewBase,
BodyLabel, setFont, PrimaryPushButton, FlyoutAnimationType)
from qfluentwidgets.components.material import AcrylicFlyoutView, AcrylicFlyoutViewBase, AcrylicFlyout
class CustomFlyoutView(AcrylicFlyoutViewBase):
def __init__(self, parent=None):
super().__init__(parent)
self.vBoxLayout = QVBoxLayout(self)
self.label = BodyLabel(
'这是一场「试炼」,我认为这就是一场为了战胜过去的「试炼」,\n只有战胜了那些幼稚的过去,人才能有所成长。')
self.button = PrimaryPushButton('Action')
self.button.setFixedWidth(140)
self.vBoxLayout.setSpacing(12)
self.vBoxLayout.setContentsMargins(20, 16, 20, 16)
self.vBoxLayout.addWidget(self.label)
self.vBoxLayout.addWidget(self.button)
class Demo(QWidget):
def __init__(self):
super().__init__()
# setTheme(Theme.DARK)
# self.setStyleSheet("Demo{background: rgb(32, 32, 32)}")
self.vBoxLayout = QHBoxLayout(self)
self.button1 = PushButton('Click Me', self)
self.button2 = PushButton('Click Me', self)
self.button3 = PushButton('Click Me', self)
self.resize(750, 550)
self.button1.setFixedWidth(150)
self.button2.setFixedWidth(150)
self.button3.setFixedWidth(150)
self.vBoxLayout.addWidget(self.button1, 0, Qt.AlignBottom)
self.vBoxLayout.addWidget(self.button2, 0, Qt.AlignBottom)
self.vBoxLayout.addWidget(self.button3, 0, Qt.AlignBottom)
self.vBoxLayout.setContentsMargins(30, 50, 30, 50)
self.button1.clicked.connect(self.showFlyout1)
self.button2.clicked.connect(self.showFlyout2)
self.button3.clicked.connect(self.showFlyout3)
def showFlyout1(self):
AcrylicFlyout.create(
icon=InfoBarIcon.SUCCESS,
title='Lesson 4',
content="表达敬意吧,表达出敬意,然后迈向回旋的另一个全新阶段!",
target=self.button1,
parent=self,
isClosable=True
)
def showFlyout2(self):
view = AcrylicFlyoutView(
title='杰洛·齐贝林',
content="触网而起的网球会落到哪一侧,谁也无法知晓。\n如果那种时刻到来,我希望「女神」是存在的。\n这样的话,不管网球落到哪一边,我都会坦然接受的吧。",
image='resource/SBR.jpg',
isClosable=True
# image='resource/yiku.gif',
)
# add button to view
button = PushButton('Action')
button.setFixedWidth(120)
view.addWidget(button, align=Qt.AlignRight)
# adjust layout (optional)
view.widgetLayout.insertSpacing(1, 5)
view.widgetLayout.addSpacing(5)
# show view
w = AcrylicFlyout.make(view, self.button2, self)
view.closed.connect(w.close)
def showFlyout3(self):
AcrylicFlyout.make(CustomFlyoutView(), self.button3, self, aniType=FlyoutAnimationType.DROP_DOWN)
if __name__ == '__main__':
app = QApplication(sys.argv)
w = Demo()
w.show()
app.exec()

View File

@ -0,0 +1,14 @@
# coding:utf-8
import sys
from PySide6.QtGui import QColor
from PySide6.QtWidgets import QApplication
from qfluentwidgets.components.widgets.acrylic_label import AcrylicLabel
app = QApplication(sys.argv)
w = AcrylicLabel(20, QColor(105, 114, 168, 102))
w.setImage('resource/埃罗芒阿老师.jpg')
w.show()
app.exec()

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

View File

@ -0,0 +1,60 @@
# coding:utf-8
import sys
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QApplication, QWidget, QHBoxLayout, QCompleter
from qfluentwidgets import LineEdit, PushButton, SearchLineEdit, setTheme, Theme
from qfluentwidgets.components.material import AcrylicSearchLineEdit
class Demo(QWidget):
def __init__(self):
super().__init__()
# self.setStyleSheet("Demo {background: rgb(32, 32, 32)}")
# setTheme(Theme.DARK)
self.hBoxLayout = QHBoxLayout(self)
self.lineEdit = AcrylicSearchLineEdit(self)
self.button = PushButton('Search', self)
# add completer
stands = [
"Star Platinum", "Hierophant Green",
"Made in Haven", "King Crimson",
"Silver Chariot", "Crazy diamond",
"Metallica", "Another One Bites The Dust",
"Heaven's Door", "Killer Queen",
"The Grateful Dead", "Stone Free",
"The World", "Sticky Fingers",
"Ozone Baby", "Love Love Deluxe",
"Hermit Purple", "Gold Experience",
"King Nothing", "Paper Moon King",
"Scary Monster", "Mandom",
"20th Century Boy", "Tusk Act 4",
"Ball Breaker", "Sex Pistols",
"D4C • Love Train", "Born This Way",
"SOFT & WET", "Paisley Park",
"Wonder of U", "Walking Heart",
"Cream Starter", "November Rain",
"Smooth Operators", "The Matte Kudasai"
]
self.completer = QCompleter(stands, self.lineEdit)
self.completer.setCaseSensitivity(Qt.CaseInsensitive)
self.completer.setMaxVisibleItems(10)
self.lineEdit.setCompleter(self.completer)
self.resize(400, 400)
self.hBoxLayout.setAlignment(Qt.AlignCenter)
self.hBoxLayout.addWidget(self.lineEdit, 0, Qt.AlignCenter)
self.hBoxLayout.addWidget(self.button, 0, Qt.AlignCenter)
self.lineEdit.setFixedSize(200, 33)
self.lineEdit.setClearButtonEnabled(True)
self.lineEdit.setPlaceholderText('Search stand')
if __name__ == '__main__':
app = QApplication(sys.argv)
w = Demo()
w.show()
app.exec()

View File

@ -0,0 +1,115 @@
# coding:utf-8
import sys
from PySide6.QtCore import Qt
from PySide6.QtGui import QIcon, QAction
from PySide6.QtWidgets import QApplication, QSystemTrayIcon
from qfluentwidgets import MessageBox, setTheme, Theme, ImageLabel, Action, MenuAnimationType, MenuItemDelegate, CheckableMenu, MenuIndicatorType
from qfluentwidgets import FluentIcon as FIF
from qfluentwidgets.components.material import AcrylicMenu, AcrylicSystemTrayMenu, AcrylicCheckableMenu
class SystemTrayIcon(QSystemTrayIcon):
def __init__(self, parent=None):
super().__init__(parent=parent)
self.setIcon(parent.windowIcon())
self.setToolTip('硝子酱一级棒卡哇伊🥰')
self.menu = AcrylicSystemTrayMenu(parent=parent)
self.menu.addActions([
Action('🎤 唱'),
Action('🕺 跳'),
Action('🤘🏼 RAP'),
Action('🎶 Music'),
Action('🏀 篮球', triggered=self.ikun),
])
self.setContextMenu(self.menu)
def ikun(self):
content = """巅峰产生虚伪的拥护,黄昏见证真正的使徒 🏀
⠀⠰⢷⢿⠄
⠀⠀⠀⠀⠀⣼⣷⣄
⠀⠀⣤⣿⣇⣿⣿⣧⣿⡄
⢴⠾⠋⠀⠀⠻⣿⣷⣿⣿⡀
⠀⢀⣿⣿⡿⢿⠈⣿
⠀⠀⠀⢠⣿⡿⠁⠀⡊⠀⠙
⠀⠀⠀⢿⣿⠀⠀⠹⣿
⠀⠀⠀⠀⠹⣷⡀⠀⣿⡄
⠀⠀⠀⠀⣀⣼⣿⠀⢈⣧
"""
w = MessageBox(
title='坤家军!集合!',
content=content,
parent=self.parent()
)
w.yesButton.setText('献出心脏')
w.cancelButton.setText('你干嘛~')
w.exec()
class Demo(ImageLabel):
def __init__(self):
super().__init__()
self.setImage("resource/chidanta.jpg")
self.scaledToWidth(500)
self.setWindowIcon(QIcon(':/qfluentwidgets/images/logo.png'))
#self.systemTrayIcon = SystemTrayIcon(self)
#self.systemTrayIcon.show()
# setTheme(Theme.DARK)
def contextMenuEvent(self, e):
menu = AcrylicMenu(parent=self)
# menu = AcrylicCheckableMenu(parent=self, indicatorType=MenuIndicatorType.RADIO)
# NOTE: hide the shortcut key
# menu.view.setItemDelegate(MenuItemDelegate())
# add actions
menu.addAction(Action(FIF.COPY, 'Copy'))
menu.addAction(Action(FIF.CUT, 'Cut'))
menu.actions()[0].setCheckable(True)
menu.actions()[0].setChecked(True)
# add sub menu
submenu = AcrylicMenu("Add to", self)
submenu.setIcon(FIF.ADD)
submenu.addActions([
Action(FIF.VIDEO, 'Video'),
Action(FIF.MUSIC, 'Music'),
])
menu.addMenu(submenu)
# add actions
menu.addActions([
Action(FIF.PASTE, 'Paste'),
Action(FIF.CANCEL, 'Undo')
])
# add separator
menu.addSeparator()
menu.addAction(QAction(f'Select all', shortcut='Ctrl+A'))
# insert actions
menu.insertAction(
menu.actions()[-1], Action(FIF.SETTING, 'Settings', shortcut='Ctrl+S'))
menu.insertActions(
menu.actions()[-1],
[Action(FIF.HELP, 'Help', shortcut='Ctrl+H'),
Action(FIF.FEEDBACK, 'Feedback', shortcut='Ctrl+F')]
)
menu.actions()[-2].setCheckable(True)
menu.actions()[-2].setChecked(True)
# show menu
menu.exec(e.globalPos(), aniType=MenuAnimationType.DROP_DOWN)
if __name__ == '__main__':
app = QApplication(sys.argv)
w = Demo()
w.show()
app.exec()

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

View File

@ -0,0 +1,55 @@
# coding:utf-8
import sys
from PySide6.QtCore import QEvent, QPoint, Qt, QUrl
from PySide6.QtGui import QDesktopServices
from PySide6.QtWidgets import QApplication, QWidget, QHBoxLayout
from qfluentwidgets import setTheme, Theme, PushButton, ToolTipPosition
from qfluentwidgets.components.material import AcrylicToolTipFilter
class Demo(QWidget):
def __init__(self):
super().__init__()
self.hBox = QHBoxLayout(self)
self.button1 = PushButton('キラキラ', self)
self.button2 = PushButton('食べた愛', self)
self.button3 = PushButton('シアワセ', self)
# use dark theme
# setTheme(Theme.DARK)
self.setStyleSheet('Demo{background:white}')
self.button1.setToolTip('aiko - キラキラ ✨')
self.button2.setToolTip('aiko - 食べた愛 🥰')
self.button3.setToolTip('aiko - シアワセ 😊')
self.button1.setToolTipDuration(1000)
# self.button2.setToolTipDuration(-1) # won't disappear
self.button1.installEventFilter(AcrylicToolTipFilter(self.button1, 0, ToolTipPosition.TOP))
self.button2.installEventFilter(AcrylicToolTipFilter(self.button2, 0, ToolTipPosition.BOTTOM))
self.button3.installEventFilter(AcrylicToolTipFilter(self.button3, 300, ToolTipPosition.RIGHT))
self.button1.clicked.connect(lambda: QDesktopServices.openUrl(QUrl(
'https://www.youtube.com/watch?v=S0bXDRY1DGM&list=RDMM&index=1')))
self.button2.clicked.connect(lambda: QDesktopServices.openUrl(QUrl(
'https://www.youtube.com/watch?v=CZLs8GuCq2U&list=RDMM&index=4')))
self.button3.clicked.connect(lambda: QDesktopServices.openUrl(QUrl(
'https://www.youtube.com/watch?v=fp-yJUB7sS8&list=RDMM&index=3')))
self.hBox.setContentsMargins(24, 24, 24, 24)
self.hBox.setSpacing(16)
self.hBox.addWidget(self.button1)
self.hBox.addWidget(self.button2)
self.hBox.addWidget(self.button3)
self.resize(480, 240)
if __name__ == '__main__':
app = QApplication(sys.argv)
w = Demo()
w.show()
app.exec()

View File

@ -0,0 +1,79 @@
# coding:utf-8
import sys
from PySide6 import QtGui
from PySide6.QtCore import Qt
from PySide6.QtGui import QIcon, QColor
from PySide6.QtWidgets import QApplication, QWidget, QLabel, QHBoxLayout
from qfluentwidgets import (RoundMenu, FluentIcon, Action, AvatarWidget, BodyLabel,
HyperlinkButton, CaptionLabel, setFont, setTheme, Theme, isDarkTheme)
from qfluentwidgets.components.material import AcrylicMenu
class ProfileCard(QWidget):
""" Profile card """
def __init__(self, avatarPath: str, name: str, email: str, parent=None):
super().__init__(parent=parent)
self.avatar = AvatarWidget(avatarPath, self)
self.nameLabel = BodyLabel(name, self)
self.emailLabel = CaptionLabel(email, self)
self.logoutButton = HyperlinkButton(
'https://qfluentwidgets.com', '注销', self)
color = QColor(206, 206, 206) if isDarkTheme() else QColor(96, 96, 96)
self.emailLabel.setStyleSheet('QLabel{color: '+color.name()+'}')
color = QColor(255, 255, 255) if isDarkTheme() else QColor(0, 0, 0)
self.nameLabel.setStyleSheet('QLabel{color: '+color.name()+'}')
setFont(self.logoutButton, 13)
self.setFixedSize(307, 82)
self.avatar.setRadius(24)
self.avatar.move(2, 6)
self.nameLabel.move(64, 13)
self.emailLabel.move(64, 32)
self.logoutButton.move(52, 48)
class Demo(QWidget):
def __init__(self):
super().__init__()
# setTheme(Theme.DARK)
# self.setStyleSheet('Demo{background: rgb(32, 32, 32)}')
self.setStyleSheet('Demo{background: white}')
self.setLayout(QHBoxLayout())
self.label = BodyLabel('Right-click your mouse', self)
self.label.setAlignment(Qt.AlignCenter)
setFont(self.label, 18)
self.layout().addWidget(self.label)
self.resize(400, 400)
def contextMenuEvent(self, e) -> None:
menu = AcrylicMenu(parent=self)
# add custom widget
card = ProfileCard('resource/shoko.png', '硝子酱', 'shokokawaii@outlook.com', menu)
menu.addWidget(card, selectable=False)
# menu.addWidget(card, selectable=True, onClick=lambda: print('666'))
menu.addSeparator()
menu.addActions([
Action(FluentIcon.PEOPLE, '管理账户和设置'),
Action(FluentIcon.SHOPPING_CART, '支付方式'),
Action(FluentIcon.CODE, '兑换代码和礼品卡'),
])
menu.addSeparator()
menu.addAction(Action(FluentIcon.SETTING, '设置'))
menu.exec(e.globalPos())
if __name__ == '__main__':
app = QApplication(sys.argv)
w = Demo()
w.show()
app.exec()

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB