fcvw has asked for the wisdom of the Perl Monks concerning the following question:

Hello,
Under Win32, you can set the icon in the bar of a Tk window using
use Tk; my $mw = MainWindow->new; my $icon = $mw->Photo(-file => 'myicon.ico'); $mw->iconimage($icon); #...place some widgets MainLoop;
For this I need a separate file with the image. Is it possible to include the image in the code?
Thanks a lot, F.

Replies are listed 'Best First'.
Re: tk: icon in bar (win32)
by PodMaster (Abbot) on May 11, 2005 at 06:52 UTC
Re: tk: icon in bar (win32)
by spurperl (Priest) on May 11, 2005 at 07:44 UTC
    Look around for the XPM format, for instance Image::XPM, and embedxpm
Re: tk: icon in bar (win32)
by zentara (Cardinal) on May 11, 2005 at 11:14 UTC
    I don't mess with win32 much, but isn't an .ico file just a .bmp file? Maybe 16x16 ?

    Anyways, you can get the bitmap from data instead of file. For example, this works on linux:


    I'm not really a human, but I play one on earth. flash japh
      This example is very clear and works great!!
      Thanks,F.
Re: tk: icon in bar (win32)
by thundergnat (Deacon) on May 11, 2005 at 11:03 UTC

    Convert it to a gif, jpg, png or xbm, then encode it in base 64. I have used a small standalone script I found in the usenet group comp.lang.perl.tk to do this if you don't want to write your own.

    Take a look at Tk::PhotoEncoder. (Not written by me, I just found it useful.)