Dr. Mu has asked for the wisdom of the Perl Monks concerning the following question:

I've recently discovered the Icon method for Tk's Toplevel windows and have used it to replace the "Tk" logo with an image of my own. However, this method seems not to honor transparent pixels, replacing them instead with opaque black. This is the case whether I use a Tk::Photo image derived from a .gif file, or a Tk::Pixmap image derived from an .xbm file. Is there a way around this apparent limitation? (I'm using ActiveState Perl 5.8 on Windows XP.)

______________________

Update: Thanks to PodMaster for pointing me to the perltk.org site. (I don't know why I never think to look there for Tk stuff. I'm more at home here, I guess.) After plumbing the depths of the forum there, I discovered the answer is that it can't be done with Photo or Pixmap images. However, there's a module, Tk::Icon, that allows one to use Windows .ico files instead. It's not on CPAN or in ActiveState's ppm repository and can be rather hard to locate. So here are the magic words required to get it via ppm:

ppm install http://www.bribes.org/perl/ppm/Tk-Icon.ppd
I tried it, and it works. BTW, you need only create a 32x32 icon. Tk will shrink it to 16x16 for you.

Thanks to Martin Schmucker for providing this useful module and to J. L. Morel of bribes.org for compiling a 5.8-compatible version and posting in his repository!

Replies are listed 'Best First'.
Re: Transparency Issues with Tk Toplevel Icons
by PodMaster (Abbot) on Mar 14, 2005 at 19:40 UTC
Re: Transparency Issues with Tk Toplevel Icons
by kvale (Monsignor) on Mar 14, 2005 at 19:37 UTC
    IIRC, you can achieve transparency effects using Tk::Pixmap with an XPM formatted image file. XBM doesn't do transparency, but XPM does.

    -Mark