How to remove a button from a gui

Hi,

I would like to remove a button from my GUI.

I tried for example

fObjectsBrowserFrame->RemoveFrame(button2); delete button2; Layout(); Resize(); MapSubwindows(); gSystem->ProcessEvents();
But the button is still kind of drawn even though I can’t click it.
How should I do ?

Hi Barth,

On which OS?
This should work (it works for me on Windows and Linux):

   fObjectsBrowserFrame->RemoveFrame(button2);
   ((TGCompositeFrame *)fObjectsBrowserFrame->GetParent())->Layout();

And as usual, if it doesn’t work for you, please send a short macro reproducing the issue :wink:

Cheers, Bertrand.

Hi Bertrand,

Thanks for the reply.
It did not work for me on Linux. Please find attached a short example. I must be doing something else wrong.
To build call “make”.

Thank you,
Barth

root_test.tgz (94.7 KB)

Hi Barth,

Here it is:

[code]void MyMainFrame::slotButton(const char* test){
cout << “test : '” << test << “’” << endl;

if (button2) {
// remove the button from its container
fObjectsBrowserFrame->RemoveFrame(button2);
// hide it
button2->UnmapWindow();
// remove its parent
button2->ReparentWindow(gClient->GetDefaultRoot());
// finally delete it
delete button2;
button2 = 0;
}
Layout();
}
[/code]
Cheers, Bertrand.

Wonderful, thank you very much !