Hi,

here is a small addon: Load once and get the Icon for every Toplevel.

package Tk::ToplevelIcon; use strict; use warnings; my $img_data = <<'img_data'; /* XPM */ static char * kologo_xpm[] = { "32 32 51 1", " c None", ". c #F32828", "+ c #000000", "@ c #FFFFFF", "# c #F3F3F3", "$ c #C2C2C2", "% c #4C4C4C", "& c #636363", "* c #464646", "= c #4E4E4E", "- c #F4F4F4", "; c #AAAAAA", "> c #161616", ", c #A3A3A3", "' c #C8C8C8", ") c #A2A2A2", "! c #FEFEFE", "~ c #222222", "{ c #141414", "] c #F9F9F9", "^ c #A1A1A1", "/ c #121212", "( c #F6F6F6", "_ c #424242", ": c #818181", "< c #717171", "[ c #414141", "} c #111111", "| c #010101", "1 c #E1E1E1", "2 c #DFDFDF", "3 c #D4D4D4", "4 c #E0E0E0", "5 c #151515", "6 c #A0A0A0", "7 c #838383", "8 c #404040", "9 c #393939", "0 c #828282", "a c #4F4F4F", "b c #242424", "c c #9D9D9D", "d c #232323", "e c #C3C3C3", "f c #C4C4C4", "g c #F32C2C", "h c #646464", "i c #F32E2E", "j c #0E0E0E", "k c #F5F5F5", "l c #0D0D0D", "................................", "................................", "..++++++++++++++++++++++++++++..", "..++++++++++++++++++++++++++++..", "..++++++++++++++++++++++++++++..", "..++++++++++++++++++++++++++++..", "..++++++++++++++++++++++++++++..", "..++++++++++++++++++++++++++++..", "..++++++++++++++++++++++++++++..", "..++++++++++++++++++++++++++++..", "..++@@@@#$%++++@@@&++++*@@@+++..", "..++@@@@@@@=+++@@-$++++;-@@+++..", "..++@@++>,@'+++@@)!~++{]^@@+++..", "..++@@+++/@(+++@@_@:++<@[@@+++..", "..++@@+++}@(+++@@|12|+34|@@+++..", "..++@@++56@'+++@@+7@89@0+@@+++..", "..++@@@@@@@a+++@@+b@6c@d+@@+++..", "..++@@@@-e%++++@@++f-#e++@@+++g.", "..++@@+++++++++@@++h@@&++@@+++i.", "..++@@+++++++++@@++jkkl++@@+++g.", "..++@@+++++++++@@++++++++@@+++..", "..++@@+++++++++@@++++++++@@+++..", "..++@@+++++++++@@++++++++@@+++..", "..++++++++++++++++++++++++++++..", "..++++++++++++++++++++++++++++..", "..++++++++++++++++++++++++++++..", "..++++++++++++++++++++++++++++..", "..++++++++++++++++++++++++++++..", "..++++++++++++++++++++++++++++..", "..++++++++++++++++++++++++++++..", "................................", "................................"}; img_data ; use Tk::Toplevel; package Tk::Toplevel; my $icon; sub InitObject{ my ($cw,$args) = @_; $cw->SUPER::InitObject($args); $icon = $cw->Pixmap(-data=>$img_data)unless $icon; # $cw->iconimage($icon);# this causes the window to flicker # during creation # let InitObject return first: $cw->afterIdle(sub{$cw->iconimage($icon)}); } 1;
usage:
use strict; use warnings; use Tk; use Tk::ToplevelIcon; tkinit; MainLoop;

Cheers, Chris

In reply to Re: Perl TK changing the logo by lamprecht
in thread Perl TK changing the logo by abachus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.