Home | News | Documentation | Download

Simple file browser

I want to write some code into my .C macro which when called, pops up a file browser which I can use to navigate my file system and choose a file. When I choose the file, a string is returned with the full path and filename of the file I chose. Can this be done with a few lines of code? Something along the lines of java’s file chooser and the example code found here…

https://docs.oracle.com/javase/7/docs/api/javax/swing/JFileChooser.html

You can open a TBrowser… ?

Thanks, I tried creating a TBrowser object, but It’s not clear how I can select a file using the GUI (The ROOT Object Browser GUI). The TBrowser is a good tool for looking at root objects like tuples or histograms I believe. In the TBrowser GUI, there is a file menu. When you click on it, in the dropdown menu, there is an “open…” command. When I click on that, I get the typical directory tree surfing file chooser GUI. I would like to just create that GUI which would allow me to select a file. When I click on the open button, the GUI should close and return a string with the full filename of the file I selected. Any pointers on the name of the GUI object which is used when I click on the “open…” command? Or any pointers to the right document to read through which details the root GUI classes?

Thanks!

I think @bellenot can help you when he will be back.

Thanks, no hurry on this one. Cheers.

Check the ${ROOTSYS}/tutorials/gui/guitest.C tutorial, in particular the File List... test