Home | News | Documentation | Download

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?

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) { 
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);
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?)

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:


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