mirror of
https://github.com/pyapp-kit/superqt.git
synced 2025-07-21 12:11:07 +02:00
feat: icon.name() (#213)
This commit is contained in:
@@ -71,5 +71,13 @@ class QIconifyIcon(QIcon):
|
||||
"Please install it with `pip install pyconify` or use the "
|
||||
"`pip install superqt[iconify]` extra."
|
||||
) from e
|
||||
if len(key) == 1:
|
||||
self._name = key[0]
|
||||
else:
|
||||
self._name = ":".join(key)
|
||||
self.path = svg_path(*key, color=color, flip=flip, rotate=rotate, dir=dir)
|
||||
super().__init__(str(self.path))
|
||||
|
||||
def name(self) -> str:
|
||||
"""Return the iconify `prefix:icon` represented by this QIcon."""
|
||||
return self._name
|
||||
|
@@ -15,6 +15,7 @@ def test_qiconify(qtbot: "QtBot", monkeypatch: "pytest.MonkeyPatch") -> None:
|
||||
|
||||
icon = QIconifyIcon("bi:alarm-fill", color="red", rotate=90)
|
||||
assert icon.path.name.endswith(".svg")
|
||||
assert icon.name() == "bi:alarm-fill"
|
||||
|
||||
btn = QPushButton()
|
||||
qtbot.addWidget(btn)
|
||||
|
Reference in New Issue
Block a user