Re: How to stop running a macro through control bar

From: Wei Xie (xiewei@ceropa.weizmann.ac.il)
Date: Thu May 14 1998 - 11:49:21 MEST


Dear Valery,

> > I can activate a macro through a control bar. How can I stop it in
> > the course of its running ?
> 
> CTRL-C should break any process (under NT it will cancel ROOT 
> though).

It seems not true. I execute the "button.C" first and click with mouse on
the button activate oo.C. But after that I can not stop unless to kill
it through keyboard.

Sincerely yours

Xie

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
***********
button.C  * 
***********

{
   gROOT->Reset();
   bar = new TControlBar("vertical", "Demos");

   bar->AddButton("activate oo.C",".x oo.C", "test for oo.C");
   bar->AddButton("Close",   "delete bar", "Delete control bar");
   bar->Show();
   gROOT->SaveContext();
}


*******
oo.C  *
*******

{
  gROOT->Reset();
  test = new TCanvas("test","",0,0,700,500);
  pad1 = new TPad("p1","",0.0, 0.0, 0.48, 0.9, 21);
  pad2 = new TPad("p2","",0.52, 0.0, 1.0, 0.9, 21);
  pad1->GetFrame()->SetFillColor(42);
  pad2->GetFrame()->SetFillColor(42);
  pad1->SetGrid();
  pad2->SetGrid();
  pad1->Draw();
  pad2->Draw();

  hist1 = new TH1F("h1","1st test hist",100, -4,4);
  hist2 = new TH1F("h2","2nd test hist",100, -4,4);
  ntuple = new TNtuple("ntuple","","x1:x2");

  hist1->SetMarkerSize(0.7);
  hist1->SetMarkerStyle(20);
  ntuple->SetMarkerStyle(21);

  hist2->SetFillColor(48);

  gRandom->SetSeed();

  float x1,x2;

  for(int i=0;i<100000;i++)
  {
   x1 = gRandom->Gaus(-1,1.5);  
   x2 = gRandom->Gaus(-0.5,0.5);  

   hist1->Fill(x1);
   hist2->Fill(x2);
   ntuple->Fill(x1,x2);

   if(!i%500)
   {
    pad1->cd();
    hist1->Draw("elp");
    hist2->Draw("same");
    pad2->cd();
    ntuple->Draw("x1:x2","x2>=0");
    test->Modified();
    test->Update();
   }
  }

  test->Update();

}



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:32 MET