forked from M-Labs/artiq
browser: use thumbnail dataset
This commit is contained in:
parent
30d557a4f8
commit
88495f2ea9
|
@ -18,10 +18,20 @@ class ResultIconProvider(QtWidgets.QFileIconProvider):
|
||||||
if not (info.isFile() and info.isReadable() and
|
if not (info.isFile() and info.isReadable() and
|
||||||
info.suffix() == "h5"):
|
info.suffix() == "h5"):
|
||||||
return
|
return
|
||||||
with h5py.File(info.filePath(), "r") as f:
|
try:
|
||||||
if "thumbnail" not in f:
|
f = h5py.File(info.filePath(), "r")
|
||||||
|
except:
|
||||||
|
return
|
||||||
|
with f:
|
||||||
|
try:
|
||||||
|
t = f["datasets/thumbnail"]
|
||||||
|
except KeyError:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
img = QtGui.QImage.fromData(t.value)
|
||||||
|
except:
|
||||||
|
logger.warning("unable to read thumbnail", exc_info=True)
|
||||||
return
|
return
|
||||||
img = QtGui.QImage.fromData(f["thumbnail"].value)
|
|
||||||
pix = QtGui.QPixmap.fromImage(img)
|
pix = QtGui.QPixmap.fromImage(img)
|
||||||
return QtGui.QIcon(pix)
|
return QtGui.QIcon(pix)
|
||||||
|
|
||||||
|
@ -82,12 +92,17 @@ class ResultsBrowser(QtWidgets.QSplitter):
|
||||||
if not (info.isFile() and info.isReadable() and
|
if not (info.isFile() and info.isReadable() and
|
||||||
info.suffix() == "h5"):
|
info.suffix() == "h5"):
|
||||||
return
|
return
|
||||||
with h5py.File(info.filePath(), "r") as f:
|
try:
|
||||||
|
f = h5py.File(info.filePath(), "r")
|
||||||
|
except:
|
||||||
|
logger.warning("unable to read HDF5 file", exc_info=True)
|
||||||
|
with f:
|
||||||
rd = {}
|
rd = {}
|
||||||
if "datasets" not in f:
|
try:
|
||||||
return
|
|
||||||
group = f["datasets"]
|
group = f["datasets"]
|
||||||
for k in group:
|
except KeyError:
|
||||||
|
return
|
||||||
|
for k in f["datasets"]:
|
||||||
rd[k] = True, group[k].value
|
rd[k] = True, group[k].value
|
||||||
self.datasets.init(rd)
|
self.datasets.init(rd)
|
||||||
|
|
||||||
|
@ -96,7 +111,6 @@ class ResultsBrowser(QtWidgets.QSplitter):
|
||||||
self.rt.expand(idx)
|
self.rt.expand(idx)
|
||||||
self.rt.scrollTo(idx)
|
self.rt.scrollTo(idx)
|
||||||
self.rt.setCurrentIndex(idx)
|
self.rt.setCurrentIndex(idx)
|
||||||
# rl root is signaled
|
|
||||||
self.rl.setCurrentIndex(self.rl_model.index(path))
|
self.rl.setCurrentIndex(self.rl_model.index(path))
|
||||||
|
|
||||||
def save_state(self):
|
def save_state(self):
|
||||||
|
|
Loading…
Reference in New Issue