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

The standard icon is a little "Tk" but I want a custom image there instead.

Originally posted as a Categorized Question.

  • Comment on How do I set the main window icon in Tkx?

Replies are listed 'Best First'.
Re: How do I set the main window icon in Tkx?
by SuicideJunkie (Vicar) on Jan 30, 2014 at 22:43 UTC

    To load a color image from a file for the icon:

    my $mw = Tkx::widget->new('.'); my $img = Tkx::image_create_photo(-file => 'icon.gif'); $mw->g_wm_iconphoto($img);

    If you have embedded data to use instead of a file (note the -data instead of -file in create_photo):

    #Pack hardcoded GIF bytes: my $icon = pack('C*' ,71,73,70,56,57,97,64,0,64,0,247,0,0,84,186, ... my $mw = Tkx::widget->new('.'); my $img = Tkx::image_create_photo(-data => $icon); $mw->g_wm_iconphoto($img);