ROOT File Browser inside of GUI

Hello,

I wanted to revisit a topic from two posts I found from a few years ago:

I have created a custom gui that I wanted to add TBrowser functionality too, so that as user can browser their local directories, open and browse root files. I have added in a TFileBrowser to my gui based on the code provided in the two threads above, and aside from some positioning problems (it doesn’t want to go where I tell it!) it seems to work and I can browse local directories. However, I cannot browse root files like one can do with a TBrowser, double clicking on the root file and having it expand much like a directory.

Is there a way to connect the double-click of a root file and enable the TFileBrowser to show the contents of the file? I have based my entire gui on the tutorial guitest.C and have implemented how it has to browse root files, but I did this as a work around to allow me access to histograms until I could create something more polished. As was pointed out previously, using the FileContainers/ListTree is hardly a professional looking solution over how the TBrowser operates.

It was suggested that the TBrowser could be edited (embed/plugin my own gui into it, add tabs to it, etc.) so that it would then have the overall functionality I want but inside of the TBrowser. I have no idea where to start for this suggestion!

Thank you for any help.


_ROOT Version:6.14.06
_Platform:Mac OSX 10.14
_Compiler:


Hi,

The ROOT Browser is quite complex and requires a lot of component. For example, browsing ROOT files is done via the virtual void Browse(TBrowser *b) method of ROOT classes. So you have to inherit from TBrowser in order to really browse objects. About signals emitted by the browser, they are:

   virtual void      BrowseObj(TObject *obj);             //*SIGNAL*
   virtual void      ExecuteDefaultAction(TObject *obj);  //*SIGNAL*
   virtual void      DoubleClicked(TObject *obj);         //*SIGNAL*
   virtual void      Checked(TObject *obj, Bool_t check); //*SIGNAL*

For embedding your own GUI, here is an example how to do it (and see also this tutorial):

   browser->StartEmbedding(TRootBrowser::kLeft);
   TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
   frmMain->SetWindowName("My Own GUI");
   frmMain->SetCleanup(kDeepCleanup);
   /// here you can populate your GUI elements

   frmMain->MapSubwindows();
   frmMain->Resize();
   frmMain->MapWindow();
   browser->StopEmbedding();
   browser->SetTabTitle("My Element", 0);

Cheers, Bertrand.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.