Editable TGedFrame

Dear ROOTers,
I’m working on some event display features. As you know for each object I can create “editor” that base on TGedFrame.
My question is how (if this possible) to build GUI after construction of such object.
I mean - when I “paint my buttons” in constructor all works fine, but when I try to add button later e.g. when SetModel is called - the GUI becomes “random mess”.
You can of course ask why I need to rebuild gui - the answer is that I would to use information from “model” to add/remove buttons. The only workaroud now it’s using singletons that are called in constructor of my editor - but I would avoid this solution.


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


I didn’t look at the TGedFrame since quite long time. Do you have some working code showing what you’re trying to do?

Hi,
It’s quite compliated to prepare minimal working example with event display. But I can provide the link to code that I’m trying to improve here FairRoot/FairEveGeoTracksEditor.cxx at nightly_master · DanielWielanek/FairRoot · GitHub.
In principle I’m trying to do lines 48-50 in SetModel method.

OK, thanks, I’ll take a look

So I took a look at the code, and I don’t see where you add/remove GUI elements (like button). And I don’t really see what you mean by

the GUI becomes “random mess”

Should I build the whole project to see the problem?

Hi, in principle yes - but this require a lot of other stuf. So I will show you what I get, so this is the part of code that I changed:

void FairEveGeoTracksEditor::SetModel(TObject *obj) { 
if(fGeoTracks==nullptr){
/**THE NEW PART OF THE CODE **/
Int_t width=80;
    TGVerticalFrame *statFrame = CreateEditorTabSubFrame("Status2");
    TGCompositeFrame *ToogleGroupFrame = new TGCompositeFrame(statFrame, width, 20, kHorizontalFrame | kFixedWidth);
    TGTextButton *ToogleGroupButton = new TGTextButton(ToogleGroupFrame, "Toggle Groups");
    ToogleGroupButton->Connect("Clicked()", this->ClassName(), this, "ToggleGroups()");
    ToogleGroupFrame->AddFrame(ToogleGroupButton, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 1, 1, 2, 1));
    statFrame->AddFrame(ToogleGroupFrame, new TGLayoutHints(kLHintsTop, 1, 1, 2, 1));
    
    FairEveIntCut *x = new FairEveIntCut(this, statFrame, "PDG", width);
    x->Init();
    x->AddUpdateButton();
}
/**END OF THE NEW PART OF THE CODE**/
fGeoTracks = dynamic_cast<FairEveGeoTracks *>(obj); 
}

In principle it mean that I should have 4 tabs - Style, Kin, Status and Status2, however I see only Style tab. When I click on another Editor (e.g. FairEveRecoTracksExample) then the GUI is repainted and tabs with button apperars, In attachement screenshot with both frames.

Can you try to add MapSubWindows() and Layout() somewhere after adding the frames?

I tried after x->AddUpdateButton(), It doesn’t help.

OK, I’ll have to dig in the code and try to reproduce it

1 Like

OK, so it’s a bit complicated to create a reproducer. What you could try is to create everything in the constructor, and then use ShowFrame() and HideFrame() in SetModel(), as it is done in TH1Editor::SetModel() for example. Otherwise, as I said, there might be a missing MapSubWindows() and Layout() somewhere in the hierarchy (parent frame? main TGTab?)

Hi,
it works when I use TGCompositeFrame however seems to not work with TGVerticalFrame created with CreateEditorTabSubFrame.

OK, so to hide the tab element itself, it’s a bit more complicated. Something like:

   fGedEditor->GetTab()->HideFrame(fGedEditor->GetTab()->GetTabTab("Status2"));

But it would be more interesting to understand why SetModel() doesn’t work properly. Can you try to add something like:

   fGedEditor->GetTab()->MapSubwindows()
   fGedEditor->GetTab()->Layout();

or

   fGedEditor->MapSubwindows()
   fGedEditor->Layout();

I tried all methods and non of them works. However I managed to create very simple example that reproduces problem (attached).
I builc magicBox library with aclic and later load to box.C macro.
box.C (1,5 KB)
magicBox.C (1,5 KB)

OK, thanks for the reproducer. It looks like you’re right, it’s not possible to properly add new tabs in ‘SetModel()’. I’ll have to debug this to understand how it works and if there is a solution. Unfortunately, that might take some time…

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