initial fluent-widgets ui
This commit is contained in:
25
examples/dialog_flyout/color_dialog/demo.py
Normal file
25
examples/dialog_flyout/color_dialog/demo.py
Normal file
@ -0,0 +1,25 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
|
||||
from PySide6.QtGui import QColor
|
||||
from PySide6.QtWidgets import QApplication, QWidget
|
||||
from qfluentwidgets import ColorPickerButton, setTheme, Theme
|
||||
|
||||
|
||||
class Demo(QWidget):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.button = ColorPickerButton(QColor("#5012aaa2"), 'Background Color', self, enableAlpha=True)
|
||||
self.resize(800, 720)
|
||||
self.button.move(352, 312)
|
||||
self.setStyleSheet("Demo{background:white}")
|
||||
|
||||
# setTheme(Theme.DARK)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
w = Demo()
|
||||
w.show()
|
||||
app.exec()
|
||||
71
examples/dialog_flyout/custom_message_box/demo.py
Normal file
71
examples/dialog_flyout/custom_message_box/demo.py
Normal file
@ -0,0 +1,71 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
|
||||
from PySide6.QtCore import Qt, QUrl
|
||||
from PySide6.QtGui import QIcon, QColor
|
||||
from PySide6.QtWidgets import QApplication, QWidget, QHBoxLayout
|
||||
|
||||
from qfluentwidgets import MessageBoxBase, SubtitleLabel, LineEdit, PushButton, CaptionLabel, setTheme, Theme
|
||||
|
||||
|
||||
class CustomMessageBox(MessageBoxBase):
|
||||
""" Custom message box """
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.titleLabel = SubtitleLabel('打开 URL', self)
|
||||
self.urlLineEdit = LineEdit(self)
|
||||
|
||||
self.urlLineEdit.setPlaceholderText('输入文件、流或者播放列表的 URL')
|
||||
self.urlLineEdit.setClearButtonEnabled(True)
|
||||
|
||||
self.warningLabel = CaptionLabel("The url is invalid")
|
||||
self.warningLabel.setTextColor("#cf1010", QColor(255, 28, 32))
|
||||
|
||||
# add widget to view layout
|
||||
self.viewLayout.addWidget(self.titleLabel)
|
||||
self.viewLayout.addWidget(self.urlLineEdit)
|
||||
self.viewLayout.addWidget(self.warningLabel)
|
||||
self.warningLabel.hide()
|
||||
|
||||
# change the text of button
|
||||
self.yesButton.setText('打开')
|
||||
self.cancelButton.setText('取消')
|
||||
|
||||
self.widget.setMinimumWidth(350)
|
||||
|
||||
# self.hideYesButton()
|
||||
|
||||
def validate(self):
|
||||
""" Rewrite the virtual method """
|
||||
isValid = self.urlLineEdit.text().lower().startswith("http://")
|
||||
self.warningLabel.setHidden(isValid)
|
||||
self.urlLineEdit.setError(not isValid)
|
||||
return isValid
|
||||
|
||||
|
||||
class Demo(QWidget):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
# setTheme(Theme.DARK)
|
||||
# self.setStyleSheet('Demo{background:rgb(32,32,32)}')
|
||||
|
||||
self.hBxoLayout = QHBoxLayout(self)
|
||||
self.button = PushButton('打开 URL', self)
|
||||
|
||||
self.resize(600, 600)
|
||||
self.hBxoLayout.addWidget(self.button, 0, Qt.AlignCenter)
|
||||
self.button.clicked.connect(self.showDialog)
|
||||
|
||||
def showDialog(self):
|
||||
w = CustomMessageBox(self)
|
||||
if w.exec():
|
||||
print(w.urlLineEdit.text())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
w = Demo()
|
||||
w.show()
|
||||
app.exec()
|
||||
37
examples/dialog_flyout/dialog/demo.py
Normal file
37
examples/dialog_flyout/dialog/demo.py
Normal file
@ -0,0 +1,37 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QApplication, QWidget
|
||||
|
||||
from qfluentwidgets import Dialog, setTheme, Theme, PrimaryPushButton
|
||||
|
||||
|
||||
class Demo(QWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.resize(950, 500)
|
||||
self.btn = PrimaryPushButton('Click Me', parent=self)
|
||||
self.btn.move(425, 225)
|
||||
self.btn.clicked.connect(self.showDialog)
|
||||
self.setStyleSheet('Demo{background:white}')
|
||||
|
||||
# setTheme(Theme.DARK)
|
||||
|
||||
def showDialog(self):
|
||||
title = 'Are you sure you want to delete the folder?'
|
||||
content = """If you delete the "Music" folder from the list, the folder will no longer appear in the list, but will not be deleted."""
|
||||
w = Dialog(title, content, self)
|
||||
# w.setTitleBarVisible(False)
|
||||
# w.setContentCopyable(True)
|
||||
if w.exec():
|
||||
print('Yes button is pressed')
|
||||
else:
|
||||
print('Cancel button is pressed')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
w = Demo()
|
||||
w.show()
|
||||
app.exec()
|
||||
93
examples/dialog_flyout/flyout/demo.py
Normal file
93
examples/dialog_flyout/flyout/demo.py
Normal file
@ -0,0 +1,93 @@
|
||||
# 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)
|
||||
|
||||
|
||||
class CustomFlyoutView(FlyoutViewBase):
|
||||
|
||||
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):
|
||||
Flyout.create(
|
||||
icon=InfoBarIcon.SUCCESS,
|
||||
title='Lesson 4',
|
||||
content="表达敬意吧,表达出敬意,然后迈向回旋的另一个全新阶段!",
|
||||
target=self.button1,
|
||||
parent=self,
|
||||
isClosable=True
|
||||
)
|
||||
|
||||
def showFlyout2(self):
|
||||
view = FlyoutView(
|
||||
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 = Flyout.make(view, self.button2, self)
|
||||
view.closed.connect(w.close)
|
||||
|
||||
def showFlyout3(self):
|
||||
Flyout.make(CustomFlyoutView(), self.button3, self, aniType=FlyoutAnimationType.DROP_DOWN)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
w = Demo()
|
||||
w.show()
|
||||
app.exec()
|
||||
BIN
examples/dialog_flyout/flyout/resource/SBR.jpg
Normal file
BIN
examples/dialog_flyout/flyout/resource/SBR.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 140 KiB |
BIN
examples/dialog_flyout/flyout/resource/yiku.gif
Normal file
BIN
examples/dialog_flyout/flyout/resource/yiku.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 MiB |
34
examples/dialog_flyout/folder_list_dialog/demo.py
Normal file
34
examples/dialog_flyout/folder_list_dialog/demo.py
Normal file
@ -0,0 +1,34 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QApplication, QWidget
|
||||
|
||||
from qfluentwidgets import FolderListDialog, setTheme, Theme, PrimaryPushButton
|
||||
|
||||
|
||||
class Demo(QWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.resize(800, 720)
|
||||
self.btn = PrimaryPushButton('Click Me', parent=self)
|
||||
self.btn.move(352, 300)
|
||||
self.btn.clicked.connect(self.showDialog)
|
||||
self.setStyleSheet('Demo{background:white}')
|
||||
|
||||
# setTheme(Theme.DARK)
|
||||
|
||||
def showDialog(self):
|
||||
folder_paths = ['D:/KuGou', 'C:/Users/shoko/Documents/Music']
|
||||
title = 'Build your collection from your local music files'
|
||||
content = "Right now, we're watching these folders:"
|
||||
w = FolderListDialog(folder_paths, title, content, self)
|
||||
w.folderChanged.connect(lambda x: print(x))
|
||||
w.exec()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
w = Demo()
|
||||
w.show()
|
||||
app.exec()
|
||||
42
examples/dialog_flyout/message_dialog/demo.py
Normal file
42
examples/dialog_flyout/message_dialog/demo.py
Normal file
@ -0,0 +1,42 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
from PySide6.QtWidgets import QApplication, QWidget
|
||||
|
||||
from qfluentwidgets import MessageDialog, MessageBox, setTheme, Theme, PrimaryPushButton
|
||||
|
||||
|
||||
class Demo(QWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.resize(1000, 500)
|
||||
self.btn = PrimaryPushButton('Click Me', parent=self)
|
||||
self.btn.move(455, 25)
|
||||
self.btn.clicked.connect(self.showDialog)
|
||||
self.setStyleSheet('Demo{background:white}')
|
||||
|
||||
# setTheme(Theme.DARK)
|
||||
|
||||
def showDialog(self):
|
||||
title = 'Are you sure you want to delete the folder?'
|
||||
content = """If you delete the "Music" folder from the list, the folder will no longer appear in the list, but will not be deleted."""
|
||||
# w = MessageDialog(title, content, self) # Win10 style message box
|
||||
w = MessageBox(title, content, self)
|
||||
|
||||
# close the message box when mask is clicked
|
||||
w.setClosableOnMaskClicked(True)
|
||||
|
||||
# enable dragging
|
||||
w.setDraggable(True)
|
||||
|
||||
if w.exec():
|
||||
print('Yes button is pressed')
|
||||
else:
|
||||
print('Cancel button is pressed')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
w = Demo()
|
||||
w.show()
|
||||
app.exec()
|
||||
106
examples/dialog_flyout/teaching_tip/demo.py
Normal file
106
examples/dialog_flyout/teaching_tip/demo.py
Normal file
@ -0,0 +1,106 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QApplication, QWidget, QHBoxLayout, QVBoxLayout
|
||||
|
||||
from qfluentwidgets import (PushButton, TeachingTip, TeachingTipTailPosition, InfoBarIcon, setTheme, Theme,
|
||||
TeachingTipView, FlyoutViewBase, BodyLabel, PrimaryPushButton, PopupTeachingTip)
|
||||
|
||||
|
||||
class CustomFlyoutView(FlyoutViewBase):
|
||||
|
||||
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)
|
||||
|
||||
def paintEvent(self, e):
|
||||
pass
|
||||
|
||||
|
||||
class Demo(QWidget):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
# setTheme(Theme.DARK)
|
||||
# self.setStyleSheet("Demo{background: rgb(32, 32, 32)}")
|
||||
|
||||
self.hBoxLayout = QHBoxLayout(self)
|
||||
self.button1 = PushButton('Top', self)
|
||||
self.button2 = PushButton('Bottom', self)
|
||||
self.button3 = PushButton('Custom', self)
|
||||
|
||||
self.resize(700, 500)
|
||||
self.button1.setFixedWidth(150)
|
||||
self.button2.setFixedWidth(150)
|
||||
self.button3.setFixedWidth(150)
|
||||
self.hBoxLayout.addWidget(self.button2, 0, Qt.AlignHCenter)
|
||||
self.hBoxLayout.addWidget(self.button1, 0, Qt.AlignHCenter)
|
||||
self.hBoxLayout.addWidget(self.button3, 0, Qt.AlignHCenter)
|
||||
self.button1.clicked.connect(self.showTopTip)
|
||||
self.button2.clicked.connect(self.showBottomTip)
|
||||
self.button3.clicked.connect(self.showCustomTip)
|
||||
|
||||
def showTopTip(self):
|
||||
position = TeachingTipTailPosition.BOTTOM
|
||||
view = TeachingTipView(
|
||||
icon=None,
|
||||
title='Lesson 5',
|
||||
content="最短的捷径就是绕远路,绕远路才是我的最短捷径。",
|
||||
image='resource/Gyro.jpg',
|
||||
# image='resource/boqi.gif',
|
||||
isClosable=True,
|
||||
tailPosition=position,
|
||||
)
|
||||
|
||||
# add widget to view
|
||||
button = PushButton('Action')
|
||||
button.setFixedWidth(120)
|
||||
view.addWidget(button, align=Qt.AlignRight)
|
||||
|
||||
w = TeachingTip.make(
|
||||
target=self.button1,
|
||||
view=view,
|
||||
duration=-1,
|
||||
tailPosition=position,
|
||||
parent=self
|
||||
)
|
||||
view.closed.connect(w.close)
|
||||
|
||||
def showBottomTip(self):
|
||||
TeachingTip.create(
|
||||
target=self.button2,
|
||||
icon=InfoBarIcon.SUCCESS,
|
||||
title='Lesson 4',
|
||||
content="表达敬意吧,表达出敬意,然后迈向回旋的另一个全新阶段!",
|
||||
isClosable=True,
|
||||
tailPosition=TeachingTipTailPosition.TOP,
|
||||
duration=2000,
|
||||
parent=self
|
||||
)
|
||||
|
||||
def showCustomTip(self):
|
||||
# TeachingTip.make(
|
||||
PopupTeachingTip.make(
|
||||
target=self.button3,
|
||||
view=CustomFlyoutView(),
|
||||
tailPosition=TeachingTipTailPosition.RIGHT,
|
||||
duration=2000,
|
||||
parent=self
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
w = Demo()
|
||||
w.show()
|
||||
app.exec()
|
||||
BIN
examples/dialog_flyout/teaching_tip/resource/Gyro.jpg
Normal file
BIN
examples/dialog_flyout/teaching_tip/resource/Gyro.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 185 KiB |
BIN
examples/dialog_flyout/teaching_tip/resource/boqi.gif
Normal file
BIN
examples/dialog_flyout/teaching_tip/resource/boqi.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 393 KiB |
Reference in New Issue
Block a user