Re: setting icon for TGMainFrame

From: Tom Roberts <tjrob_at_fnal.gov>
Date: Mon, 10 Sep 2007 12:24:46 -0500


This is driving me crazy! Here's my code (inside a large macro):

         // set Gui.IconPath
         char tmp[1024];
         sprintf(tmp,"%s:%s",getenv("HOME"),
				gEnv->GetValue("Gui.IconPath","."));
         assert(strlen(tmp)<sizeof(tmp)); // snprintf() not available
         gEnv->SetValue("Gui.IconPath",tmp);
printf("Gui.IconPath='%s'\n",gEnv->GetValue("Gui.IconPath","."));
         window = new TGMainFrame(gClient->GetRoot(),200,200,
				kVerticalFrame);
         window->SetIconPixmap("historooticon.png");


Here's the output on Linux:

Gui.IconPath='/home/tjrob:/home/tjrob/icons:/home/tjrob/root/icons:.' root [1] .!ls -l /home/tjrob/historooticon.png -rw-r--r-- 1 tjrob tjrob 591 Sep 10 11:56 /home/tjrob/historooticon.png

That output looks fine, BUT I GET THE WRONG ICON (the default X-windows "X").

If I copy historooticon.png to either /home/tjrob/root/icons or "." then I get the correct icon.

What is going on? Why doesn't it use the updated Gui.IconPath?

Tom Roberts

Ilka Antcheva wrote:
> Hi Tom,
>
> Define for your class const TGPicture *fIconPic;
> In your class constructor use:
> fIconPic = SetIconPixmap("your_icon.png");
> In your class destructor (to avoid memory leak):
> if (fIconPic) gClient->FreePicture(fIconPic);
>
> If you need to specify in addition the special path to the icon
> directory, you may have a look at
> http://root.cern.ch/phpBB2/viewtopic.php?t=5390
>
> Cheers, Ilka
>
> Tom Roberts wrote:

>> My Root application is implemented as a TGMainFrame. How can I set the 
>> icon for this window? The documentation is obscure ("... this is 
>> typically done via the window manager", but no hint how to do that).
>>
>> I need to handle Windows, Linux, and Mac OS X, and have versions of my 
>> icon in .ico, .png, and .icns formats.
>>
>>
>> Tom Roberts
>>
Received on Mon Sep 10 2007 - 19:33:18 CEST

This archive was generated by hypermail 2.2.0 : Tue Sep 11 2007 - 05:50:01 CEST