提交 88fb2c71 编写于 作者: 之一Yo's avatar 之一Yo

添加各种尺寸的标签

上级 1e0c0f77
......@@ -8,16 +8,8 @@ QScrollArea {
border: none;
}
ToolBar > #titleLabel {
font: 28px 'Segoe UI SemiBold', 'Microsoft YaHei';
font-weight: bold;
background-color: transparent;
color: white;
}
ToolBar > #subtitleLabel {
font: 12px 'Segoe UI', 'Microsoft YaHei';
background-color: transparent;
ToolBar>CaptionLabel {
color: white;
}
......
......@@ -25,13 +25,6 @@ IconCardView {
background-color: transparent;
}
#iconLibraryLabel {
font: 14px 'Segoe UI Light', 'Microsoft YaHei';
background-color: transparent;
font-weight: 700;
color: white;
}
#iconView {
border: 1px solid rgb(36, 36, 36);
border-radius: 10px;
......
......@@ -6,15 +6,7 @@ QScrollArea {
border: none;
}
ToolBar > #titleLabel {
font: 28px 'Segoe UI SemiBold', 'Microsoft YaHei';
background-color: transparent;
color: black;
}
ToolBar > #subtitleLabel {
font: 12px 'Segoe UI', 'Microsoft YaHei';
background-color: transparent;
ToolBar > CaptionLabel {
color: rgb(95, 95, 95);
}
......
......@@ -55,9 +55,3 @@ IconInfoPanel > QLabel {
color: rgb(96, 96, 96);
}
#iconLibraryLabel {
font: 14px 'Segoe UI Light', 'Microsoft YaHei';
font-weight: 700;
background-color: transparent;
color: black;
}
......@@ -4,7 +4,8 @@ from PyQt5.QtGui import QDesktopServices, QPainter, QPen, QColor
from PyQt5.QtWidgets import QWidget, QLabel, QVBoxLayout, QHBoxLayout, QFrame
from qfluentwidgets import (ScrollArea, PushButton, ToolButton, FluentIcon,
isDarkTheme, IconWidget, Theme, ToolTipFilter)
isDarkTheme, IconWidget, Theme, ToolTipFilter, TitleLabel, CaptionLabel,
StrongBodyLabel, BodyLabel)
from ..common.config import cfg, FEEDBACK_URL, HELP_URL, EXAMPLE_URL
from ..common.icon import Icon
from ..common.style_sheet import StyleSheet
......@@ -35,8 +36,8 @@ class ToolBar(QWidget):
def __init__(self, title, subtitle, parent=None):
super().__init__(parent=parent)
self.titleLabel = QLabel(title, self)
self.subtitleLabel = QLabel(subtitle, self)
self.titleLabel = TitleLabel(title, self)
self.subtitleLabel = CaptionLabel(subtitle, self)
self.documentButton = PushButton(
self.tr('Documentation'), self, FluentIcon.DOCUMENT)
......@@ -81,9 +82,6 @@ class ToolBar(QWidget):
self.supportButton.setToolTip(self.tr('Support me'))
self.feedbackButton.setToolTip(self.tr('Send feedback'))
self.titleLabel.setObjectName('titleLabel')
self.subtitleLabel.setObjectName('subtitleLabel')
self.themeButton.clicked.connect(self.toggleTheme)
self.supportButton.clicked.connect(signalBus.supportSignal)
self.documentButton.clicked.connect(
......@@ -106,12 +104,12 @@ class ExampleCard(QWidget):
self.widget = widget
self.stretch = stretch
self.titleLabel = QLabel(title, self)
self.titleLabel = StrongBodyLabel(title, self)
self.card = QFrame(self)
self.sourceWidget = QFrame(self.card)
self.sourcePath = sourcePath
self.sourcePathLabel = QLabel(
self.sourcePathLabel = BodyLabel(
self.tr('Source code'), self.sourceWidget)
self.linkIcon = IconWidget(FluentIcon.LINK, self.sourceWidget)
......@@ -129,9 +127,7 @@ class ExampleCard(QWidget):
self.sourceWidget.setCursor(Qt.PointingHandCursor)
self.sourceWidget.installEventFilter(self)
self.titleLabel.setObjectName('titleLabel')
self.card.setObjectName('card')
self.sourcePathLabel.setObjectName('sourcePathLabel')
self.sourceWidget.setObjectName('sourceWidget')
def __initLayout(self):
......
......@@ -4,7 +4,8 @@ from typing import List
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtWidgets import QApplication, QFrame, QVBoxLayout, QLabel, QWidget, QHBoxLayout
from qfluentwidgets import (FluentIcon, IconWidget, FlowLayout, isDarkTheme,
Theme, applyThemeColor, SmoothScrollArea, SearchLineEdit)
Theme, applyThemeColor, SmoothScrollArea, SearchLineEdit, StrongBodyLabel,
BodyLabel)
from .gallery_interface import GalleryInterface
from ..common.translator import Translator
......@@ -120,7 +121,7 @@ class IconCardView(QWidget):
def __init__(self, parent=None):
super().__init__(parent=parent)
self.trie = Trie()
self.iconLibraryLabel = QLabel(self.tr('Fluent Icons Library'), self)
self.iconLibraryLabel = StrongBodyLabel(self.tr('Fluent Icons Library'), self)
self.searchLineEdit = LineEdit(self)
self.view = QFrame(self)
......@@ -193,7 +194,6 @@ class IconCardView(QWidget):
def __setQss(self):
self.view.setObjectName('iconView')
self.scrollWidget.setObjectName('scrollWidget')
self.iconLibraryLabel.setObjectName('iconLibraryLabel')
StyleSheet.ICON_INTERFACE.apply(self)
......
# coding:utf-8
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout
from qfluentwidgets import (CaptionLabel, BodyLabel, StrongBodyLabel, SubtitleLabel, TitleLabel,
LargeTitleLabel, DisplayLabel, setTheme, Theme)
class Demo(QWidget):
def __init__(self):
super().__init__()
self.vBoxLayout = QVBoxLayout(self)
self.vBoxLayout.setContentsMargins(30, 30, 30, 30)
self.vBoxLayout.setSpacing(20)
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(0).widget().setTextColor('#009faa', '#009faa')
# setTheme(Theme.DARK)
# self.setStyleSheet("QWidget{background: rgb(32, 32, 32)}")
if __name__ == '__main__':
# enable dpi scale
QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
app = QApplication(sys.argv)
w = Demo()
w.show()
app.exec_()
\ No newline at end of file
......@@ -19,33 +19,6 @@ class ContainerPlugin(PluginBase):
return True
class FramelessMainWindowPlugin(ContainerPlugin, QPyDesignerCustomWidgetPlugin):
""" Frameless main window plugin """
def createWidget(self, parent):
return FramelessMainWindow(parent)
def icon(self):
return super().icon("TitleBar")
def name(self):
return "FramelessMainWindow"
class FramelessWindowPlugin(ContainerPlugin, QPyDesignerCustomWidgetPlugin):
""" Frameless window plugin """
def createWidget(self, parent):
return FramelessWindow(parent)
def icon(self):
return super().icon("TitleBar")
def name(self):
return "FramelessWindow"
class ScrollAreaPluginBase(ContainerPlugin):
""" Scroll area plugin base """
......
# coding: utf-8
from PyQt5.QtCore import Qt
from PyQt5.QtDesigner import QPyDesignerCustomWidgetPlugin
from qfluentwidgets import (BodyLabel, CaptionLabel, StrongBodyLabel, SubtitleLabel, TitleLabel, LargeTitleLabel,
DisplayLabel)
from plugin_base import PluginBase
class LabelPlugin(PluginBase):
def group(self):
return super().group() + ' (Label)'
def domXml(self):
return f"""
<widget class="{self.name()}" name="{self.name()}">
<property name="text">
<string>{self.toolTip()}</string>
</property>
</widget>
"""
class CaptionLabelPlugin(LabelPlugin, QPyDesignerCustomWidgetPlugin):
""" Caption label plugin """
def createWidget(self, parent):
return CaptionLabel(parent)
def icon(self):
return super().icon("TextBlock")
def name(self):
return "CaptionLabel"
class BodyLabelPlugin(LabelPlugin, QPyDesignerCustomWidgetPlugin):
""" Body label plugin """
def createWidget(self, parent):
return BodyLabel(parent)
def icon(self):
return super().icon("TextBlock")
def name(self):
return "BodyLabel"
class StrongBodyLabelPlugin(LabelPlugin, QPyDesignerCustomWidgetPlugin):
""" Strong body label plugin """
def createWidget(self, parent):
return StrongBodyLabel(parent)
def icon(self):
return super().icon("TextBlock")
def name(self):
return "StrongBodyLabel"
class SubtitleLabelPlugin(LabelPlugin, QPyDesignerCustomWidgetPlugin):
""" Subtitle label plugin """
def createWidget(self, parent):
return SubtitleLabel(parent)
def icon(self):
return super().icon("TextBlock")
def name(self):
return "SubtitleLabel"
class TitleLabelPlugin(LabelPlugin, QPyDesignerCustomWidgetPlugin):
""" Title label plugin """
def createWidget(self, parent):
return TitleLabel(parent)
def icon(self):
return super().icon("TextBlock")
def name(self):
return "TitleLabel"
class LargeTitleLabelPlugin(LabelPlugin, QPyDesignerCustomWidgetPlugin):
""" Title label plugin """
def createWidget(self, parent):
return LargeTitleLabel(parent)
def icon(self):
return super().icon("TextBlock")
def name(self):
return "LargeTitleLabel"
class DisplayLabelPlugin(LabelPlugin, QPyDesignerCustomWidgetPlugin):
""" Display label plugin """
def createWidget(self, parent):
return DisplayLabel(parent)
def icon(self):
return super().icon("TextBlock")
def name(self):
return "DisplayLabel"
......@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/ma
:license: GPLv3, see LICENSE for more details.
"""
__version__ = "0.9.5"
__version__ = "0.9.6"
from .components import *
from .common import *
......
......@@ -4,7 +4,6 @@ SettingCardGroup {
SettingCardGroup>QLabel {
background-color: transparent;
font: 20px 'Segoe UI', 'Microsoft YaHei';
color: white;
border: none;
}
......@@ -4,7 +4,6 @@ SettingCardGroup {
SettingCardGroup>QLabel {
background-color: transparent;
font: 20px 'Segoe UI', 'Microsoft YaHei';
color: black;
border: none;
}
\ No newline at end of file
此差异已折叠。
......@@ -3,7 +3,7 @@ from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QWidget
def setFont(widget: QWidget, fontSize=14):
def setFont(widget: QWidget, fontSize=14, weight=QFont.Normal):
""" set the font of widget
Parameters
......@@ -13,19 +13,26 @@ def setFont(widget: QWidget, fontSize=14):
fontSize: int
font pixel size
weight: `QFont.Weight`
font weight
"""
widget.setFont(getFont(fontSize))
widget.setFont(getFont(fontSize, weight))
def getFont(fontSize=14):
def getFont(fontSize=14, weight=QFont.Normal):
""" create font
Parameters
----------
fontSize: int
font pixel size
weight: `QFont.Weight`
font weight
"""
font = QFont()
font.setFamilies(['Segoe UI', 'Microsoft YaHei'])
font.setPixelSize(fontSize)
font.setWeight(weight)
return font
\ No newline at end of file
......@@ -5,6 +5,7 @@ from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QLabel, QVBoxLayout
from ...common.style_sheet import FluentStyleSheet
from ...common.font import setFont
from ..layout.expand_layout import ExpandLayout
......@@ -28,6 +29,7 @@ class SettingCardGroup(QWidget):
self.vBoxLayout.addLayout(self.cardLayout, 1)
FluentStyleSheet.SETTING_CARD_GROUP.apply(self)
setFont(self.titleLabel, 20)
self.titleLabel.adjustSize()
def addSettingCard(self, card: QWidget):
......
......@@ -8,7 +8,8 @@ from .check_box import CheckBox
from .combo_box import ComboBox, EditableComboBox
from .line_edit import LineEdit, TextEdit, PlainTextEdit, LineEditButton, SearchLineEdit
from .icon_widget import IconWidget
from .label import PixmapLabel
from .label import (PixmapLabel, CaptionLabel, StrongBodyLabel, BodyLabel, SubtitleLabel, TitleLabel,
LargeTitleLabel, DisplayLabel, FluentLabelBase)
from .list_view import ListWidget, ListView, ListItemDelegate
from .menu import DWMMenu, LineEditMenu, RoundMenu, MenuAnimationManager, MenuAnimationType
from .info_bar import InfoBar, InfoBarIcon, InfoBarPosition
......
# coding:utf-8
from typing import List
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap, QPainter
from PyQt5.QtWidgets import QLabel
from PyQt5.QtGui import QPixmap, QPainter, QPalette, QColor, QFont
from PyQt5.QtWidgets import QLabel, QWidget
from ...common.overload import singledispatchmethod
from ...common.font import setFont, getFont
from ...common.config import qconfig, isDarkTheme
class PixmapLabel(QLabel):
......@@ -28,3 +34,91 @@ class PixmapLabel(QLabel):
QPainter.SmoothPixmapTransform)
painter.setPen(Qt.NoPen)
painter.drawPixmap(self.rect(), self.__pixmap)
class FluentLabelBase(QLabel):
""" Fluent label base class """
@singledispatchmethod
def __init__(self, parent: QWidget = None):
super().__init__(parent)
self._init()
@__init__.register
def _(self, text: str, parent: QWidget = None):
self.__init__(parent)
self.setText(text)
def _init(self):
self.setFont(self.getFont())
self.setTextColor()
qconfig.themeChanged.connect(lambda: self.setTextColor())
return self
def getFont(self):
raise NotImplementedError
def setTextColor(self, light=QColor(0, 0, 0), dark=QColor(255, 255, 255)):
""" set the text color of label
Parameters
----------
light, dark: QColor | Qt.GlobalColor | str
text color in light/dark mode
"""
self.lightColor = QColor(light)
self.darkColor = QColor(dark)
palette = self.palette()
color = self.darkColor if isDarkTheme() else self.lightColor
palette.setColor(QPalette.WindowText, color)
self.setPalette(palette)
class CaptionLabel(FluentLabelBase):
""" Caption text label """
def getFont(self):
return getFont(12)
class BodyLabel(FluentLabelBase):
""" Body text label """
def getFont(self):
return getFont(14)
class StrongBodyLabel(FluentLabelBase):
""" Strong body text label """
def getFont(self):
return getFont(14, QFont.DemiBold)
class SubtitleLabel(FluentLabelBase):
""" Sub title text label """
def getFont(self):
return getFont(20, QFont.DemiBold)
class TitleLabel(FluentLabelBase):
""" Sub title text label """
def getFont(self):
return getFont(28, QFont.DemiBold)
class LargeTitleLabel(FluentLabelBase):
""" Large title text label """
def getFont(self):
return getFont(40, QFont.DemiBold)
class DisplayLabel(FluentLabelBase):
""" Display text label """
def getFont(self):
return getFont(68, QFont.DemiBold)
......@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools.setup(
name="PyQt-Fluent-Widgets",
version="0.9.5",
version="0.9.6",
keywords="pyqt fluent widgets",
author="zhiyiYo",
author_email="shokokawaii@outlook.com",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册