http://www.perlmonks.org?node_id=34950

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: (gui programming)

I can't figure out how to use

$toplevel->iconbitmap(?bitmap?)

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: How do I change the icon on Toplevel?
by Clachair (Acolyte) on Apr 29, 2001 at 05:02 UTC
Re: How do I change the icon on Toplevel?
by Anonymous Monk on Mar 13, 2002 at 17:43 UTC

    Check out the $toplevel->Icon method. Here's a short example:

    my $image = $top->Photo( -data => $imageDat, -format => 'gif' ); $top->Icon( -image => $image );
    I tested this on ActiveState Perl 5.6.1 build 631, Tk 800.023.

Re: How do I change the icon on Toplevel?
by Anonymous Monk on Nov 10, 2003 at 15:38 UTC
    # define the icon's data: my $my_icon_data = <<'EOF'; /* XPM */ static char *main[]={ "32 32 3 1", "# c #1655fe", ". c #ffffff", "$ c #fbc819", "................................", "................#...............", . ...the rest of your really cool pixel art here... . "......####............####......", "......####............####......",}; EOF # associate that with the image name 'my_icon': $main->Pixmap( 'my_icon', -data => $my_icon_data ); # use the image as an icon on any TopLevel: $toplevel->Icon( -image => 'my_icon' );

    I've tested the above in Windows XP and Linux.

    See Tk::Pixmap for info on XPM files.

      What a convoluted mess. All you do is:
      my $img = $tl->Photo(-file => "path_to_image"); $tl->Icon(-image => $img);
      And substitute a Pixmap or Image for the Photo if necessary.

      Are you sure it was a book? Are you sure it wasn't.....nothing?
Re: How do I change the icon on Toplevel?
by $code or die (Deacon) on Oct 05, 2000 at 19:32 UTC
    Hi Anonymous,

    This is an interesting question. I have found some answers on usenet but I can't get any of them to work.

    There is the iconbitmap method you describe, and I also came across the iconimage method, but I had similar problems.

    The explanations I have come across did not go into much detail about what format the icon had to be in. I assume that a standard windows .ico file is no good.

    I would like to get my hands on a copy of Learning PerlTk from O'Reilly but my local library doesn't have it.

    Sorry I can't help at the moment, but when I work it out, I will post some sample code here with explanations.

    Good Luck!

    Originally posted as a Categorized Answer.