Skip to content

Commit 0290b23

Browse files
committed
Fix blurry SVG icons in Icon Browser by using QIcon for proper vector rendering
1 parent bc5c71e commit 0290b23

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

guidata/widgets/iconbrowser.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,27 @@ def _create_icon_widget(self, icon_path: str) -> QW.QWidget:
149149
icon_label.setAlignment(QC.Qt.AlignCenter)
150150

151151
# Load and set icon
152-
pixmap = QG.QPixmap(icon_path)
153-
if not pixmap.isNull():
154-
scaled_pixmap = pixmap.scaled(
155-
self.icon_size,
156-
self.icon_size,
157-
QC.Qt.KeepAspectRatio,
158-
QC.Qt.SmoothTransformation,
159-
)
160-
icon_label.setPixmap(scaled_pixmap)
152+
if icon_path.lower().endswith(".svg"):
153+
# For SVG files, use QIcon which renders them properly at any size
154+
icon = QG.QIcon(icon_path)
155+
pixmap = icon.pixmap(self.icon_size, self.icon_size)
156+
if not pixmap.isNull():
157+
icon_label.setPixmap(pixmap)
158+
else:
159+
icon_label.setText("Error")
161160
else:
162-
icon_label.setText("Error")
161+
# For raster images, use QPixmap
162+
pixmap = QG.QPixmap(icon_path)
163+
if not pixmap.isNull():
164+
scaled_pixmap = pixmap.scaled(
165+
self.icon_size,
166+
self.icon_size,
167+
QC.Qt.KeepAspectRatio,
168+
QC.Qt.SmoothTransformation,
169+
)
170+
icon_label.setPixmap(scaled_pixmap)
171+
else:
172+
icon_label.setText("Error")
163173

164174
# Filename label
165175
filename = osp.basename(icon_path)

0 commit comments

Comments
 (0)