How to remove a button from a gui


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):

   ((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,

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
// hide it
// remove its parent
// finally delete it
delete button2;
button2 = 0;
Cheers, Bertrand.

Wonderful, thank you very much !