silx
silx copied to clipboard
[help wanted] how to interact with `silx.app.view.Viewer.Viewer`
I am using silx with jupyter lab to build notebook-script using some interactive windows.
I would like to use the Viewer to select the data that my code will use.
What I'd like to do is to get the full url (object or string) of something selected in a file tree window.
For instance, in the image below, I'd like to programmatically get the value of that path (having access to the Viewer object).

Hi,
If the tree is enough for you, you could try to use h5glance It will provide to you an integrated tree.
I don't know the state of other notebooks viewers currently in dev.
The Viewer was not designed to be used in such way, so it will be a bit complex. But you could try:
selected = list(viewer._Viewer__treeview.selectedH5Nodes())
print(selected[0].local_basename)
I did not checked if it is working, there is probably a typo here and there.
Hi,
I confirm, the code from @vallsv works:
from silx import sx
from silx.app.view.Viewer import Viewer
viewer = Viewer()
viewer.show()
selection = list(viewer._Viewer__treeview.selectedH5Nodes())
print(selection[0].local_filename, selection[0].local_basename)
but it is not meant to be used this way.
Also, silx view provides drag&drop from the tree widget, so you can drag a dataset/group from silx view to the notebook, which will be copied as: silx://<filename>?/hdf5/path.
This URL can be used with silx.io:
import silx.io
dataset = silx.io.open("silx://<filename>?/hdf5/path")
There is also a recent HDF5 file viewer integrated in JupyterLab: jupyterlab-h5web and some doc. There will be a new release in the coming days. It is integrated in the notebook (with JupyterLab) and allows to browse and view HDF5 file "a la" silx view. You can't retrieve programmatically the selected HDF5 path, but you can copy it from the top bar, and it's integrated in the notebook so no need to switch between applications.
Hi, thank you for you advices. I ended up using h5glance.
However, I noticed that it is not possible to use qt applications when i am running jupyter lab in another machine.
Are there ipywidget versions of the gui tools provided in silx? Or something that could be adapted?
Are there ipywidget versions of the gui tools provided in silx?
No, it's a completely different software stack. Which tools do you need?
Which tools do you need?
Mostly the 3d dataset viewer.
Closing as a solution was given. Do not hesitate to re-open if more discussion is needed.