If I understand you correctly, no, you can't easily change the default icon in the title bar of a messageBox. Mostly because the messageBox megawidget will auto display as soon as it is created, not allowing you any time to modify the window managers defaults.

You can however, use a Dialog (which messageBox is based on), since it is not automatically displayed as soon as it is created. It takes a little more work, but allows greater flexibility.

#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Dialog; my $top = MainWindow->new; # a 32x32 gif image MIME64 encoded my $icon = $top->Photo(-format => 'gif', -data => ' R0lGODlhIAAgALMAACcREeOxI1lSTJ6XlW5padXNvLOspYF5cnFoV5KKfdnX1j44Ntq9Xv +v8+vjy wL65uiH5BAAAAAAALAAAAAAgACAAAwT/sMlJq7046837VsUjjkY5FkraPaUxigZBmLARav +CQlEM/ HIeeYWBIJISKi6KlOw5GB4JzaCTalM/iAUGw/ggCaeIwdg2VVHK1FwXLEGPjcIDWAoEyAv +eNuAeJ GQ89RwiFAgsCAgiJiYUHJUkZBS1ai4yFcEY7BR0gRQlgh41kT5EeFAQAqgIFKKcZqauvGw +eqAAKz DAwOFwK2BK8OAQEMF7G3F4KcFcLDvb8WCbZ0FQzEFg8LCwDaphIGtgkWRbwTCqAEeIkHFb +UGyQvl LF8+R4dEkX0YD2T8fXc+yICJougHAgwDRCFC1IWNjCjabvU5uE9TooHp3iTStsDIAW8UZg +ro2ILJ IyZFmBwZQWhkoko4ZAxtVATkwYUB6frokRIET5tQjRAYMKUAp4EohtLJERiF5KVFC6iBWU +BAgYyg OVNa0taI44IkAiDi5BqUqiI9jBZKo7rgXUKgjAYSPMQ1IiK62thFAAA7 '); # set up the dialog my $dialog = $top->Dialog( -bitmap => 'warning', -text => 'Danger Will Robinson!', -title => 'Robot Says', -buttons => [qw(Run! Flee! Panic!)], ); # Modify the default icon $dialog->Icon(-image => $icon); # display it my $answer = $dialog->Show; print $answer; MainLoop;

In reply to Re: Missing TK Messagebox icons by thundergnat
in thread Missing TK Messagebox icons by schimkat

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.