Skip to content

Commit

Permalink
feat: icon.name() (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 authored Oct 23, 2023
1 parent 3efafd7 commit bd68991
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/superqt/iconify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,13 @@ def __init__(
"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
1 change: 1 addition & 0 deletions tests/test_iconify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bd68991

Please sign in to comment.