text_interface.py 4.1 KB
Newer Older
之一Yo's avatar
之一Yo 已提交
1
# coding:utf-8
之一Yo's avatar
之一Yo 已提交
2 3 4
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QCompleter
from qfluentwidgets import LineEdit, SpinBox, DoubleSpinBox, TimeEdit, DateTimeEdit, DateEdit, TextEdit, SearchLineEdit
之一Yo's avatar
之一Yo 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

from .gallery_interface import GalleryInterface
from ..common.translator import Translator


class TextInterface(GalleryInterface):
    """ Text interface """

    def __init__(self, parent=None):
        t = Translator()
        super().__init__(
            title=t.text,
            subtitle="qfluentwidgets.components.widgets",
            parent=parent
        )

之一Yo's avatar
之一Yo 已提交
21
        # line edit
22 23
        lineEdit = LineEdit(self)
        lineEdit.setText(self.tr('ko no dio da!'))
之一Yo's avatar
之一Yo 已提交
24 25 26 27 28 29 30
        lineEdit.setClearButtonEnabled(True)
        self.addExampleCard(
            title=self.tr("A LineEdit with a clear button"),
            widget=lineEdit,
            sourcePath='https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/line_edit/demo.py'
        )

之一Yo's avatar
之一Yo 已提交
31 32
        # line edit with completer
        lineEdit = SearchLineEdit(self)
之一Yo's avatar
之一Yo 已提交
33
        lineEdit.setPlaceholderText(self.tr('Type a stand name'))
之一Yo's avatar
之一Yo 已提交
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
        lineEdit.setClearButtonEnabled(True)
        lineEdit.setFixedWidth(230)
        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"
        ]
        completer = QCompleter(stands, lineEdit)
        completer.setCaseSensitivity(Qt.CaseInsensitive)
        lineEdit.setCompleter(completer)

        self.addExampleCard(
            title=self.tr("A autosuggest line edit"),
            widget=lineEdit,
            sourcePath='https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/line_edit/demo.py'
        )

之一Yo's avatar
之一Yo 已提交
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
        # spin box
        self.addExampleCard(
            title=self.tr("A SpinBox with a spin button"),
            widget=SpinBox(self),
            sourcePath='https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/spin_box/demo.py'
        )

        # double spin box
        self.addExampleCard(
            title=self.tr("A DoubleSpinBox with a spin button"),
            widget=DoubleSpinBox(self),
            sourcePath='https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/spin_box/demo.py'
        )

        # date edit
        self.addExampleCard(
            title=self.tr("A DateEdit with a spin button"),
            widget=DateEdit(self),
            sourcePath='https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/spin_box/demo.py'
        )

        # time edit
        self.addExampleCard(
            title=self.tr("A TimeEdit with a spin button"),
            widget=TimeEdit(self),
            sourcePath='https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/spin_box/demo.py'
        )

        # date time edit
        self.addExampleCard(
            title=self.tr("A DateTimeEdit with a spin button"),
            widget=DateTimeEdit(self),
            sourcePath='https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/spin_box/demo.py'
        )
100 101 102 103 104 105 106 107 108 109 110 111

        # text edit
        textEdit = TextEdit(self)
        textEdit.setMarkdown(
            "## Steel Ball Run \n * Johnny Joestar 🦄 \n * Gyro Zeppeli 🐴 ")
        textEdit.setFixedHeight(150)
        self.addExampleCard(
            title=self.tr("A simple TextEdit"),
            widget=textEdit,
            sourcePath='https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/line_edit/demo.py',
            stretch=1
        )