Hi Roman,
OK, Here is a working version of your code (source only). Now adding and removing frames works (I tried on Windows and Linux SLC4 gcc3.4)
Note you cannot add (create) and remove GUI elements from different
threads. It has to be done from the main thread.
So I created two extra buttons ("Add Cluster" and "Remove Cluster")
instead of the command line thread you are using to add and remove
clusters...
But this is another subject, the issue of adding/removing frames is
solved.
Cheers, Bertrand.
-----Original Message-----
From: Bertrand Bellenot
Sent: Thursday, April 15, 2010 09:59
To: Bertrand Bellenot; rl_at_hep.ph.bham.ac.uk
Cc: Rene Brun; roottalk
Subject: RE: [ROOT] root GUI
Hi again,
Sorry, I was wrong, this code is NOT a proper solution:
GCluster::~GCluster()
{
delete button;
delete fC;
}
Since GCluster is not the parent frame... Anyway, I'll take a look today and see if there is a simple solution.
Cheers, Bertrand.
-----Original Message-----
From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch]
On Behalf Of Bertrand Bellenot
Sent: Thursday, April 15, 2010 09:54
To: rl_at_hep.ph.bham.ac.uk
Cc: Rene Brun; roottalk
Subject: RE: [ROOT] root GUI
Hi Roman,
So apparently I was not clear enough in my previous post, sorry about
that.
Replacing DeleteWindow() calls with DestroyWindow() is not a solution!
So, just to clarify, this code is WRONG:
GCluster::~GCluster()
{
//Remove frames
fC->DestroyWindow();
ftop->RemoveFrame(fC);
//delete fC;
button->DestroyWindow();
ftop->RemoveFrame(button);
//delete button;
}
...
void MyMainFrame::AddExit()
{
if(exit) {
exit->DestroyWindow();
fMain->RemoveFrame(exit);
//delete exit;
}
exit = new TGTextButton(fMain,"&Exit","gApplication->Terminate(0)");
fMain->AddFrame(exit, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
}
You MUST NOT CALL "DeleteWindow()" or "DestroyWindow()" on GUI
Widgets!!!
Please take a look in the examples in $(ROOTSYS)/tutorials/gui
The code above should look like this:
GCluster::~GCluster()
{
delete button;
delete fC;
}
void MyMainFrame::AddExit()
{
if(exit) {
fMain->RemoveFrame(exit);
delete exit;
}
exit = new TGTextButton(fMain,"&Exit","gApplication->Terminate(0)");
fMain->AddFrame(exit, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
}
And please send me a WORKING piece of code (your code crashes on all
platforms) with a proper makefile (yours doesn't generates the
dictionary)
Could you also tell me which ROOT version, which platform, and which
compiler you are using?
Cheers, Bertrand.
-----Original Message-----
From: Roman Lietava [mailto:rl_at_hep.ph.bham.ac.uk]
Sent: Wednesday, April 14, 2010 23:46
To: Bertrand Bellenot
Cc: Rene Brun; roottalk
Subject: RE: [ROOT] root GUI
Hi Bertrand,
thanks for suggestions, I've used them.
Code behaves now a bit better.
But crashes when I want to add third window (second is ok).
Also windows resizing is not perfect.
Please, have a look.
Thanks,
Roman.
On Mon, 12 Apr 2010, Bertrand Bellenot wrote:
> Hi Roman,
> >> I try to add/delete/modify windows dynamically, e.g. when run >> starts,stop.
> >> - is there somewhere example of gui with similar functionality ?
> >> - is there other documentation apart from >> ftp://root.cern.ch/root/doc/25WritingGUI.pdf ?
> >> - how can I debug errors a la bad windows ?
> which is not valid anymore...
>
>
>
>
>
>
>
>
>
> >
>
>
> > > >
--Received on Thu Apr 15 2010 - 13:18:42 CEST
- application/x-compressed attachment: test.tgz
This archive was generated by hypermail 2.2.0 : Thu Apr 15 2010 - 17:50:01 CEST