Skip to content

Commit bc5c71e

Browse files
committed
Add Icon Browser utility for browsing icon collections
- New guidata.widgets.iconbrowser module with IconBrowserWindow widget - Command-line tool: giconbrowser [folder] - Split-pane UI: tree view (folder hierarchy) + icon grid display - Single-click icons to open file location in system explorer - Adjustable thumbnail sizes (16-256px), multiple format support - Dynamic folder icons (open/closed), responsive layout - Includes About dialog and pytest-compatible test suite
1 parent 9d64fa5 commit bc5c71e

File tree

7 files changed

+634
-2
lines changed

7 files changed

+634
-2
lines changed

.vscode/tasks.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,5 +388,30 @@
388388
"🧹 Clean Up",
389389
],
390390
},
391+
{
392+
"label": "🖼️ Icon Browser",
393+
"command": "${command:python.interpreterPath}",
394+
"args": [
395+
"-m",
396+
"guidata.widgets.iconbrowser",
397+
"${workspaceFolder}/guidata/data/icons",
398+
],
399+
"options": {
400+
"cwd": "${workspaceFolder}",
401+
},
402+
"group": {
403+
"kind": "build",
404+
"isDefault": true,
405+
},
406+
"presentation": {
407+
"clear": true,
408+
"echo": true,
409+
"focus": false,
410+
"panel": "dedicated",
411+
"reveal": "always",
412+
"showReuseMessage": true,
413+
},
414+
"type": "shell",
415+
},
391416
],
392417
}

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog #
22

3+
## Version 3.14.0 ##
4+
5+
✨ New features:
6+
7+
* **Icon Browser utility**: Added a new GUI tool for browsing and exploring icon collections
8+
* New `guidata.widgets.iconbrowser` module with `IconBrowserWindow` widget
9+
* Command-line tool: `giconbrowser [folder]` or `python -m guidata.widgets.iconbrowser [folder]`
10+
* Features a split-pane interface with tree view for folder navigation and icon grid display
11+
* Tree view shows folder hierarchy with open/closed folder icons and file counts
12+
* Single-click on icons opens file location in system file explorer (Windows/macOS/Linux)
13+
* Adjustable thumbnail sizes (16-256 pixels) via toolbar
14+
* Supports PNG, SVG, ICO, JPG, GIF, and BMP formats
15+
* Responsive grid layout adapts to window resizing
16+
* Useful for developers managing icons for their applications and libraries
17+
318
## Version 3.13.3 ##
419

520
🛠️ Bug fixes:
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Licensed under the terms of the BSD 3-Clause
4+
# (see guidata/LICENSE for details)
5+
6+
"""
7+
Icon Browser Test
8+
==================
9+
10+
Test for the icon browser widget.
11+
"""
12+
13+
# guitest: show
14+
15+
from __future__ import annotations
16+
17+
import os.path as osp
18+
19+
from guidata.env import execenv
20+
from guidata.qthelpers import qt_app_context
21+
from guidata.widgets.iconbrowser import IconBrowserWindow
22+
23+
24+
def get_guidata_icons_path() -> str:
25+
"""Get the path to guidata's icon directory.
26+
27+
Returns:
28+
Path to the icons directory
29+
"""
30+
import guidata
31+
32+
guidata_path = osp.dirname(guidata.__file__)
33+
icons_path = osp.join(guidata_path, "data", "icons")
34+
return icons_path
35+
36+
37+
def test_iconbrowser():
38+
"""Test the icon browser widget."""
39+
with qt_app_context(exec_loop=not execenv.unattended):
40+
icons_dir = get_guidata_icons_path()
41+
window = IconBrowserWindow(init_folder=icons_dir)
42+
window.resize(900, 600)
43+
window.show()
44+
if not execenv.unattended:
45+
window.activateWindow()
46+
47+
48+
if __name__ == "__main__":
49+
test_iconbrowser()

guidata/widgets/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,11 @@
2929
3030
.. autoclass:: guidata.widgets.codeeditor.CodeEditor
3131
32+
Utilities
33+
^^^^^^^^^
34+
35+
.. autoclass:: guidata.widgets.iconbrowser.IconBrowserWindow
36+
37+
.. autofunction:: guidata.widgets.iconbrowser.main
38+
3239
"""

guidata/widgets/arrayeditor/datamodel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ def data(self, index: QModelIndex, role=Qt.ItemDataRole.DisplayRole) -> Any:
491491
return ""
492492
try:
493493
return self._format % value
494-
except TypeError:
494+
except (TypeError, ValueError, ZeroDivisionError):
495495
self.readonly = True
496496
return repr(value)
497497
elif role == Qt.ItemDataRole.TextAlignmentRole:
@@ -508,7 +508,7 @@ def data(self, index: QModelIndex, role=Qt.ItemDataRole.DisplayRole) -> Any:
508508
hue = float(np.abs(hue))
509509
color = QColor.fromHsvF(hue, self.sat, self.val, self.alp)
510510
return color
511-
except TypeError:
511+
except (TypeError, ValueError, ZeroDivisionError):
512512
return None
513513
elif role == Qt.ItemDataRole.FontRole:
514514
return get_font(CONF, "arrayeditor", "font")

0 commit comments

Comments
 (0)