@@ -17,6 +17,7 @@ from qtpy.QtWidgets import (
|
||||
)
|
||||
from qtpy.QtCore import Qt
|
||||
from qtpy.QtGui import QFont, QColor
|
||||
from qtpy.QtWidgets import QStyle
|
||||
|
||||
import pyqtgraph as pg
|
||||
|
||||
@@ -43,8 +44,8 @@ STYLESHEET = f"""
|
||||
QMainWindow, QWidget {{
|
||||
background-color: {BG_DARK};
|
||||
color: {TEXT_PRI};
|
||||
font-family: 'Inter', 'Segoe UI', 'Helvetica Neue', sans-serif;
|
||||
font-size: 13px;
|
||||
# font-family: 'Inter', 'Segoe UI', 'Helvetica Neue', sans-serif;
|
||||
# font-size: 13px;
|
||||
}}
|
||||
QSplitter::handle {{
|
||||
background: {BORDER};
|
||||
@@ -148,23 +149,39 @@ def dtype_tag(ds):
|
||||
|
||||
|
||||
def populate_tree(parent_item, h5_obj):
|
||||
style = QApplication.style()
|
||||
folder_icon = style.standardIcon(QStyle.SP_DirIcon)
|
||||
file_icon = style.standardIcon(QStyle.SP_FileIcon)
|
||||
|
||||
if not isinstance(h5_obj, h5py.Group):
|
||||
return
|
||||
|
||||
for key in h5_obj.keys():
|
||||
child = h5_obj[key]
|
||||
try:
|
||||
child = h5_obj[key]
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
if isinstance(child, h5py.Group):
|
||||
label = f"{TYPE_ICONS['group']} {key}"
|
||||
item = QTreeWidgetItem(parent_item, [label, "Group", ""])
|
||||
item = QTreeWidgetItem(parent_item, [key, "Group", ""])
|
||||
item.setIcon(0, folder_icon)
|
||||
|
||||
item.setData(0, Qt.UserRole, child.name)
|
||||
item.setData(0, Qt.UserRole + 1, "group")
|
||||
|
||||
item.setForeground(0, QColor(ACCENT))
|
||||
|
||||
populate_tree(item, child)
|
||||
|
||||
elif isinstance(child, h5py.Dataset):
|
||||
shape_str = "×".join(str(s) for s in child.shape) or "scalar"
|
||||
label = f"{TYPE_ICONS['dataset']} {key}"
|
||||
item = QTreeWidgetItem(parent_item, [label, dtype_tag(child), shape_str])
|
||||
|
||||
item = QTreeWidgetItem(parent_item, [key, dtype_tag(child), shape_str])
|
||||
item.setIcon(0, file_icon)
|
||||
|
||||
item.setData(0, Qt.UserRole, child.name)
|
||||
item.setData(0, Qt.UserRole + 1, "dataset")
|
||||
|
||||
item.setForeground(1, QColor(SUCCESS))
|
||||
item.setForeground(2, QColor(TEXT_SEC))
|
||||
|
||||
@@ -464,7 +481,10 @@ class HDF5Viewer(QMainWindow):
|
||||
def _load_tree(self):
|
||||
self.tree.clear()
|
||||
|
||||
root_item = QTreeWidgetItem(self.tree, ["📂 /", "Group", ""])
|
||||
style = QApplication.style()
|
||||
folder_icon = style.standardIcon(QStyle.SP_DirIcon) # TODO Choose different icon for head
|
||||
root_item = QTreeWidgetItem(self.tree, ["/", "Group", ""])
|
||||
root_item.setIcon(0, folder_icon)
|
||||
root_item.setData(0, Qt.UserRole, "/")
|
||||
root_item.setData(0, Qt.UserRole + 1, "group")
|
||||
root_item.setForeground(0, QColor(ACCENT))
|
||||
@@ -493,9 +513,9 @@ class HDF5Viewer(QMainWindow):
|
||||
ds = self.h5file[path]
|
||||
data = ds[()]
|
||||
self.data_panel.display(data, path)
|
||||
self.status.showMessage(
|
||||
f"{path} | shape {ds.shape} | dtype {ds.dtype}"
|
||||
)
|
||||
# self.status.showMessage(
|
||||
# f"{path} | shape {ds.shape} | dtype {ds.dtype}"
|
||||
# )
|
||||
else:
|
||||
n = len(obj) if isinstance(obj, h5py.Group) else 0
|
||||
# self.status.showMessage(
|
||||
|
||||
Reference in New Issue
Block a user