diff --git a/src/superqt/iconify/__init__.py b/src/superqt/iconify/__init__.py index 75fd123d..c47860cd 100644 --- a/src/superqt/iconify/__init__.py +++ b/src/superqt/iconify/__init__.py @@ -81,7 +81,8 @@ def __init__( "`pip install superqt[iconify]` extra." ) super().__init__() - self.addKey(*key, color=color, flip=flip, rotate=rotate, dir=dir) + if key: + self.addKey(*key, color=color, flip=flip, rotate=rotate, dir=dir) def addKey( self, @@ -93,7 +94,7 @@ def addKey( size: QSize | None = None, mode: QIcon.Mode = QIcon.Mode.Normal, state: QIcon.State = QIcon.State.Off, - ) -> None: + ) -> QIconifyIcon: """Add an icon to this QIcon. This is a variant of `QIcon.addFile` that uses an iconify icon keys and @@ -123,6 +124,11 @@ def addKey( Mode specified for the icon, passed to `QIcon.addFile`. state : QIcon.State, optional State specified for the icon, passed to `QIcon.addFile`. + + Returns + ------- + QIconifyIcon + This QIconifyIcon instance, for chaining. """ try: path = svg_path(*key, color=color, flip=flip, rotate=rotate, dir=dir) @@ -135,6 +141,8 @@ def addKey( else: self.addFile(str(path), size or QSize(), mode, state) + return self + def _draw_text_fallback(self, key: tuple[str, ...]) -> None: if style := QApplication.style(): pixmap = style.standardPixmap(style.StandardPixmap.SP_MessageBoxQuestion)