feat: icon.name() (#213)

This commit is contained in:
Talley Lambert
2023-10-23 11:20:59 -04:00
committed by GitHub
parent 3efafd7aa8
commit bd6899133f
2 changed files with 9 additions and 0 deletions

View File

@@ -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

View File

@@ -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)