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.
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.
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?)
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…