Re: root GUI

From: Bertrand Bellenot <bertrand.bellenot_at_cern.ch>
Date: Thu, 15 Apr 2010 19:13:49 +0200


Hi Roman,

Here is a possible solution, using a timer to create the clusters (timers are processed by the main thread). Even if it is not the perfect solution for you, it may give you some ideas.

Cheers, Bertrand.

Roman Lietava wrote:
> Thanks a lot, Bertrand.
> Yes, it works now.
>
> Actually the problem of different threads is also problem.
> mythread in test/main.cxx emulates DIM thread in the full code,
> which receives information about creating/destroying clusters
> (and so windows).
> So I need communication between threads:
> when the mythread (or DIM) finds it should modify GUI
> it needs to tell it other thread. I am looking in thread
> documentation. Please, let me know,
> if you have any suggestions, what to use.
> Thanks,
> Roman.
>
>
> On Thu, 15 Apr 2010, Bertrand Bellenot wrote:
>
>> 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.
>>> This should work, as long as you do it right, for example, You should
>>> use this method to close a Window: mainwin->CloseWindow()
>>>
>>>> - is there somewhere example of gui with similar functionality ?
>>> Depends which functionality... You can take a look at examples in
>>> $ROOTSYS/tutorials/gui/*.C and at $ROOTSYS/test/guitest
>>>
>>>> - is there other documentation apart from
>>>> ftp://root.cern.ch/root/doc/25WritingGUI.pdf ?
>>> No, this is the only available documentation for the time being...
>>>
>>>> - how can I debug errors a la bad windows ?
>>> You can use gdb, and for the meaning of e.g. "XREQ: 40", you can take
>>> a look there:
>>> http://www.rahul.net/kenton/xproto/xrequests.html
>>> XREQ:40 = TranslateCoords
>>> Meaning you (the application) try to translate coordinates of a Window
>>
>>> which is not valid anymore...
>>>
>>> If you still have problems, you can send your code (or the relevant
>>> part)
>>> and we'll take a look...
>>>
>>> Cheers, Bertrand.
>>>
>>> -----Original Message-----
>>> From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch]
>>> On Behalf Of Roman Lietava
>>> Sent: Monday, April 12, 2010 07:37
>>> To: Rene Brun
>>> Cc: roottalk
>>> Subject: [ROOT] root GUI
>>>
>>> I am trying to use to write standalone code with root GUI classes
>>> (TGxxxx).
>>>
>>> I try to add/delete/modify windows dynamically, e.g. when run
>>> starts,stop.
>>>
>>> It sometimes works, but quite often it crashes, see output pasted
>>> after email.
>>>
>>> My questions are following:
>>>
>>> - 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 ?
>>>
>>> Thanks,
>>> Roman.
>>>
>>>
>>> ""
>>> Starting DisplaySCAL for run: 113081
>>> fInputs=0x9e99ca8
>>> Cleanup ok
>>> fComp added
>>> Warning in <TCanvas::ResizePad>: fRootEmbeddedCanvas19_canvas width
>>> changed from 0 to 10
>>>
>>> Warning in <TCanvas::ResizePad>: fRootEmbeddedCanvas19_canvas height
>>> changed from 0 to 10
>>>
>>> Inputs added
>>> run 113081 adding cluster 0
>>> Error in <RootX11ErrorHandler>: BadWindow (invalid Window parameter)
>>> (XID:
>>> 10486057, XREQ: 40)
>>> ""
>>>
>>>
>>>
>>>
>>
>>
>

Received on Thu Apr 15 2010 - 19:14:23 CEST

This archive was generated by hypermail 2.2.0 : Fri Apr 16 2010 - 11:50:01 CEST