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

Dear monks,

I am writing a Perl/Tk application (Perl 5.8.8) and need to change the default image that appears on the upper-left corner of the window with another logo. I have successfully done that in Windows (XP, Vista) using an .ico file with the following code snippet
$mw = new MainWindow (-title => "My Perl/Tk app"); my $newlogo = $mw->setIcon(-file => $imagedir."logo.ico");
I need to do the same for a MAC OS X (10.5.6) system. The only fairly relevant information I could find implies a Linux system and suggests to do the following:

1. Take an image (i.e. png, jpeg etc) and convert it into a .xpm
I did this using the convert command of ImageMagick:
convert logo.png logo.xpm
2. Try the following code snippet:
$mw = new MainWindow (-title => "My Perl/Tk app"); my $newlogo = $mw->Photo(-file => $imagedir."logo.xpm", -format => 'xp +m'); $mw->Icon(-image => $newlogo);
However, the upper-left-corner image still remains the default (actually, in MAC it is not the standard red-ish Tk image that used to appear in Windows systems, but the black and white X11 image). Any suggestions are very welcome!

Thanks in advance,
Athanasia

Replies are listed 'Best First'.
Re: Change default image of Perl/Tk in MAC OS X
by cmv (Chaplain) on Apr 08, 2016 at 14:26 UTC
    Hi Monks-

    I am currently fighting this issue as well.

    I have searched the web high and low, but cannot find a solution that works to change the logo on a mac.

    Is this a Perl-Tk issue? An XQuartz issue? Some other issue?

    Has anyone ever figured this out? Please help if you can.

    Thanks

    -Craig

        Hi beech-

        Thanks for the reply, and the pointer to Slaven's examples.

        This particular example you cite, works fine on a PC, but does not work on the Mac. The iconimage line should change the title-bar icon to look like what is in icon.gif, and have that image used by the window manager when the application is iconified.

        In either case, the Mac still shows the (seemingly hardcoded) X-windows icon as the title-bar icon, and the dock shows a miniaturized screenshot of what the application looks like, when iconized.

        Looking through other examples there, I also find the following:

        https://metacpan.org/source/SREZIC/Tk-804.033/examples/iconimg

        In this example, each time you hit any of the buttons, the title-bar icon should change to look like the image in that button. This also fails on the Mac.

        Has anyone ever been able to make either of these work on a Mac, since the dawn of time? If so, please reply here.

        If not, I'll go ahead and create a bug report.

        Thanks

        -Craig