initial fluent-widgets ui
This commit is contained in:
66
examples/text/font_icon/demo.py
Normal file
66
examples/text/font_icon/demo.py
Normal file
@ -0,0 +1,66 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtGui import QIcon
|
||||
from PySide6.QtWidgets import QApplication, QWidget, QHBoxLayout
|
||||
|
||||
from qfluentwidgets import FluentFontIconBase, Theme, PushButton, SwitchButton, TogglePushButton, toggleTheme, HyperlinkButton
|
||||
|
||||
|
||||
class PhotoFontIcon(FluentFontIconBase):
|
||||
""" Custom icon font icon """
|
||||
|
||||
def path(self, theme=Theme.AUTO):
|
||||
return "font/PhotosIcons.ttf"
|
||||
|
||||
def iconNameMapPath(self):
|
||||
""" Not necessary, but if you want to use `fromName`, you have to implement this method """
|
||||
return "font/PhotoIcons.json"
|
||||
|
||||
|
||||
class MediaPlayerFontIcon(FluentFontIconBase):
|
||||
""" Custom icon font icon """
|
||||
|
||||
def path(self, theme=Theme.AUTO):
|
||||
return "font/MediaPlayerIcons.ttf"
|
||||
|
||||
|
||||
class Demo(QWidget):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.themeButton = SwitchButton(self)
|
||||
|
||||
self.button1 = PushButton(PhotoFontIcon("\ue77b"), "Default")
|
||||
self.button2 = PushButton(PhotoFontIcon.fromName("cloud").colored("#275EFF", Qt.GlobalColor.darkCyan), "Custom")
|
||||
self.button3 = TogglePushButton(PhotoFontIcon.fromName("smile"), "Toggle")
|
||||
self.button4 = HyperlinkButton(MediaPlayerFontIcon("\uf414"), "http://qfluentwidgets.com", "Hyperlink")
|
||||
self.hBoxLayout = QHBoxLayout(self)
|
||||
|
||||
self.hBoxLayout.addWidget(self.button1)
|
||||
self.hBoxLayout.addWidget(self.button2)
|
||||
self.hBoxLayout.addWidget(self.button3)
|
||||
self.hBoxLayout.addWidget(self.button4)
|
||||
|
||||
self.resize(500, 500)
|
||||
self.themeButton.move(200, 50)
|
||||
self.themeButton.setOnText("Dark")
|
||||
self.themeButton.setOffText("Light")
|
||||
|
||||
self.themeButton.checkedChanged.connect(self.toggleTheme)
|
||||
|
||||
def toggleTheme(self, isCheked):
|
||||
toggleTheme()
|
||||
if isCheked:
|
||||
self.setStyleSheet("Demo{background:rgb(32,32,32)}")
|
||||
else:
|
||||
self.setStyleSheet("Demo{background:rgb(242,242,242)}")
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
w = Demo()
|
||||
w.show()
|
||||
app.exec()
|
||||
BIN
examples/text/font_icon/font/MediaPlayerIcons.ttf
Normal file
BIN
examples/text/font_icon/font/MediaPlayerIcons.ttf
Normal file
Binary file not shown.
5
examples/text/font_icon/font/PhotoIcons.json
Normal file
5
examples/text/font_icon/font/PhotoIcons.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"cloud": "\ue753",
|
||||
"filter": "\ue71c",
|
||||
"smile": "\ue76e"
|
||||
}
|
||||
BIN
examples/text/font_icon/font/PhotosIcons.ttf
Normal file
BIN
examples/text/font_icon/font/PhotosIcons.ttf
Normal file
Binary file not shown.
36
examples/text/image_label/demo.py
Normal file
36
examples/text/image_label/demo.py
Normal file
@ -0,0 +1,36 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtGui import QIcon
|
||||
from PySide6.QtWidgets import QApplication, QWidget, QHBoxLayout, QVBoxLayout
|
||||
|
||||
from qfluentwidgets import ImageLabel
|
||||
|
||||
|
||||
class Demo(QWidget):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.imageLabel = ImageLabel("resource/Gyro.jpg")
|
||||
self.gifLabel = ImageLabel("resource/boqi.gif")
|
||||
self.vBoxLayout = QVBoxLayout(self)
|
||||
|
||||
# change image
|
||||
# self.imageLabel.setImage("resource/boqi.gif")
|
||||
|
||||
self.imageLabel.scaledToHeight(300)
|
||||
self.gifLabel.scaledToHeight(300)
|
||||
|
||||
self.imageLabel.setBorderRadius(0, 30, 30, 0)
|
||||
self.gifLabel.setBorderRadius(10, 10, 10, 10)
|
||||
|
||||
self.vBoxLayout.addWidget(self.imageLabel)
|
||||
self.vBoxLayout.addWidget(self.gifLabel)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
w = Demo()
|
||||
w.show()
|
||||
app.exec()
|
||||
BIN
examples/text/image_label/resource/Gyro.jpg
Normal file
BIN
examples/text/image_label/resource/Gyro.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 185 KiB |
BIN
examples/text/image_label/resource/boqi.gif
Normal file
BIN
examples/text/image_label/resource/boqi.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 393 KiB |
43
examples/text/label/demo.py
Normal file
43
examples/text/label/demo.py
Normal file
@ -0,0 +1,43 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
|
||||
from PySide6.QtCore import Qt, QUrl
|
||||
from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout
|
||||
from qfluentwidgets import (CaptionLabel, BodyLabel, StrongBodyLabel, SubtitleLabel, TitleLabel,
|
||||
LargeTitleLabel, DisplayLabel, setTheme, Theme, HyperlinkLabel, setFont)
|
||||
|
||||
|
||||
class Demo(QWidget):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.vBoxLayout = QVBoxLayout(self)
|
||||
self.vBoxLayout.setContentsMargins(30, 30, 30, 30)
|
||||
self.vBoxLayout.setSpacing(20)
|
||||
|
||||
self.hyperlinkLabel = HyperlinkLabel(QUrl('https://github.com/'), 'GitHub')
|
||||
# self.hyperlinkLabel.setUrl('https://qfluentwidgets.com')
|
||||
# self.hyperlinkLabel.setUnderlineVisible(True)
|
||||
# setFont(self.hyperlinkLabel, 18)
|
||||
|
||||
self.vBoxLayout.addWidget(self.hyperlinkLabel)
|
||||
self.vBoxLayout.addWidget(CaptionLabel('Caption'))
|
||||
self.vBoxLayout.addWidget(BodyLabel('Body'))
|
||||
self.vBoxLayout.addWidget(StrongBodyLabel('Body Strong'))
|
||||
self.vBoxLayout.addWidget(SubtitleLabel('Subtitle'))
|
||||
self.vBoxLayout.addWidget(TitleLabel('Title'))
|
||||
self.vBoxLayout.addWidget(LargeTitleLabel('Title Large'))
|
||||
self.vBoxLayout.addWidget(DisplayLabel('Display'))
|
||||
|
||||
# customize text color
|
||||
# self.vBoxLayout.itemAt(1).widget().setTextColor('#009faa', '#009faa')
|
||||
|
||||
# setTheme(Theme.DARK)
|
||||
# self.setStyleSheet("QWidget{background: rgb(32, 32, 32)}")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
w = Demo()
|
||||
w.show()
|
||||
app.exec()
|
||||
60
examples/text/line_edit/demo.py
Normal file
60
examples/text/line_edit/demo.py
Normal 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
|
||||
|
||||
|
||||
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 = SearchLineEdit(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()
|
||||
61
examples/text/spin_box/demo.py
Normal file
61
examples/text/spin_box/demo.py
Normal file
@ -0,0 +1,61 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QApplication, QWidget, QGridLayout
|
||||
|
||||
from qfluentwidgets import (SpinBox, CompactSpinBox, DoubleSpinBox, CompactDoubleSpinBox,
|
||||
DateTimeEdit, CompactDateTimeEdit, DateEdit, CompactDateEdit,
|
||||
TimeEdit, CompactTimeEdit, setTheme, Theme)
|
||||
|
||||
|
||||
class Demo(QWidget):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
# setTheme(Theme.DARK)
|
||||
self.setStyleSheet('Demo{background: rgb(255, 255, 255)}')
|
||||
|
||||
self.gridLayout = QGridLayout(self)
|
||||
|
||||
self.spinBox = SpinBox(self)
|
||||
self.compactSpinBox = CompactSpinBox(self)
|
||||
self.spinBox.setAccelerated(True)
|
||||
self.compactSpinBox.setAccelerated(True)
|
||||
|
||||
self.timeEdit = TimeEdit(self)
|
||||
self.compactTimeEdit = CompactTimeEdit(self)
|
||||
|
||||
self.dateEdit = DateEdit(self)
|
||||
self.compactDateEdit = CompactDateEdit(self)
|
||||
|
||||
self.dateTimeEdit = DateTimeEdit(self)
|
||||
self.compactDateTimeEdit = CompactDateTimeEdit(self)
|
||||
|
||||
self.doubleSpinBox = DoubleSpinBox(self)
|
||||
self.compactDoubleSpinBox = CompactDoubleSpinBox(self)
|
||||
|
||||
self.resize(500, 500)
|
||||
self.gridLayout.setHorizontalSpacing(30)
|
||||
|
||||
self.gridLayout.setContentsMargins(100, 50, 100, 50)
|
||||
self.gridLayout.addWidget(self.spinBox, 0, 0)
|
||||
self.gridLayout.addWidget(self.compactSpinBox, 0, 1, Qt.AlignLeft)
|
||||
|
||||
self.gridLayout.addWidget(self.doubleSpinBox, 1, 0)
|
||||
self.gridLayout.addWidget(self.compactDoubleSpinBox, 1, 1, Qt.AlignLeft)
|
||||
|
||||
self.gridLayout.addWidget(self.timeEdit, 2, 0)
|
||||
self.gridLayout.addWidget(self.compactTimeEdit, 2, 1, Qt.AlignLeft)
|
||||
|
||||
self.gridLayout.addWidget(self.dateEdit, 3, 0)
|
||||
self.gridLayout.addWidget(self.compactDateEdit, 3, 1, Qt.AlignLeft)
|
||||
|
||||
self.gridLayout.addWidget(self.dateTimeEdit, 4, 0)
|
||||
self.gridLayout.addWidget(self.compactDateTimeEdit, 4, 1, Qt.AlignLeft)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
w = Demo()
|
||||
w.show()
|
||||
app.exec()
|
||||
32
examples/text/text_browser/demo.py
Normal file
32
examples/text/text_browser/demo.py
Normal file
@ -0,0 +1,32 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QApplication, QWidget, QHBoxLayout, QCompleter
|
||||
|
||||
from qfluentwidgets import LineEdit, PushButton, TextBrowser, setTheme, Theme
|
||||
|
||||
|
||||
class Demo(QWidget):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
# self.setStyleSheet("Demo {background: rgb(32, 32, 32)}")
|
||||
# setTheme(Theme.DARK)
|
||||
|
||||
self.hBoxLayout = QHBoxLayout(self)
|
||||
self.textBrowser = TextBrowser(self)
|
||||
|
||||
# add completer
|
||||
self.resize(400, 400)
|
||||
self.hBoxLayout.setAlignment(Qt.AlignCenter)
|
||||
self.hBoxLayout.addWidget(self.textBrowser, 0, Qt.AlignCenter)
|
||||
|
||||
self.textBrowser.setPlaceholderText('Search stand')
|
||||
self.textBrowser.setMarkdown("## Steel Ball Run \n * Johnny Joestar 🦄 \n * Gyro Zeppeli 🐴")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
w = Demo()
|
||||
w.show()
|
||||
app.exec()
|
||||
Reference in New Issue
Block a user