File: fonticon3.py

package info (click to toggle)
superqt 0.7.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,328 kB
  • sloc: python: 9,162; makefile: 16; sh: 12
file content (41 lines) | stat: -rw-r--r-- 938 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
try:
    from fonticon_fa5 import FA5S
except ImportError as e:
    raise type(e)(
        "This example requires the fontawesome fontpack:\n\n"
        "pip install git+https://github.com/tlambert03/fonticon-fontawesome5.git"
    )

from qtpy.QtCore import QSize
from qtpy.QtWidgets import QApplication, QPushButton

from superqt.fonticon import IconOpts, icon, pulse, spin

app = QApplication([])

btn = QPushButton()
btn.setIcon(
    icon(
        FA5S.smile,
        color="blue",
        states={
            "active": IconOpts(
                glyph_key=FA5S.spinner,
                color="red",
                scale_factor=0.5,
                animation=pulse(btn),
            ),
            "disabled": {"color": "green", "scale_factor": 0.8, "animation": spin(btn)},
        },
    )
)
btn.setIconSize(QSize(256, 256))
btn.show()


@btn.clicked.connect
def toggle_state():
    btn.setChecked(not btn.isChecked())


app.exec()