Home > Archive > PerlTk > November 2004 > Re: Add window icon to messageBox?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: Add window icon to messageBox?
|
|
| Johnny Google 2004-11-03, 3:56 pm |
| I thought I would ask this again in 2004 to see if there has been an
update ... is there a way to add a window icon to messageBox?
Or is there an equivalent YesNo type widget that I can add a window
icon to?
| |
| zentara 2004-11-04, 8:56 am |
| On 3 Nov 2004 09:00:40 -0800, "Johnny Google" <john_pataki@yahoo.com>
wrote:
>I thought I would ask this again in 2004 to see if there has been an
>update ... is there a way to add a window icon to messageBox?
>
>Or is there an equivalent YesNo type widget that I can add a window
>icon to?
Are you talking about on win32?
From perldoc Tk::messageBox
-icon
Specifies an icon to display. On X11 any of the
builtin Tk bitmaps can specified. On Windows only
error, info, question or warning are supported.
########################################
##
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
my $mw = tkinit;
$mw->Button(-text=>'Press Me',
-command => sub{
my $message = localtime;
&send_message( $message) }
)->pack;
MainLoop;
sub send_message{
my $message = shift;
$mw->messageBox(
-background => 'lightyellow',
-icon => 'error',
-message => $message,
-type => 'OK'
);
}
########################################
#####
Or you can define your own bitmap. I don't know if
you can get the bitmap color different from the foreground.
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
my $mw = tkinit;
my $bits = pack("b8"x8,
"...11...",
"..1111..",
".111111.",
"11111111",
"11111111",
".111111.",
"..1111..",
"...11...",);
$mw->DefineBitmap('indicator' => 8,8, $bits);
$mw->Button(-text=>'Press Me',
-command => sub{
my $message = localtime;
&send_message( $message) }
)->pack;
MainLoop;
sub send_message{
my $message = shift;
$mw->messageBox(
-background => 'lightyellow',
-foreground => 'red',
-icon => 'indicator',
-message => $message,
-type => 'OK'
);
}
########################################
#####
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
| |
| Richard S Beckett 2004-11-04, 8:56 am |
| Is there a way to change the icon in the top left corner of something like a
MessageBox?
R.
| |
| Marc Dashevsky 2004-11-04, 3:57 pm |
| In article <cmd8h2$sh1$1@newshost.mot.com>, spikeywan@bigfoot.com says...
> Is there a way to change the icon in the top left corner of something like a
> MessageBox?
You may know that on Windows, you can change the window manager icon
of the main window if you have a 32x32 .bmp of .gif as follows:
use Tk;
my $mw = tkinit;
my $image = 'tag.gif'; # 32x32 GIF or BMP
my $icon = $mw->Photo(-file => $image);
$mw->idletasks; # this line is crucial
$mw->iconimage($icon);
MainLoop;
Add the following lines before MainLoop to change the icon of
a Dialog or DialogBox:
my $d = $mw->Dialog(-text => 'Test');
$d->iconimage($icon);
$d->Show;
You cannot use this approach with the messageBox method, but
you can convert your code to use Dialog or DialogBox.
--
Go to http://MarcDashevsky.com to send me e-mail.
|
|
|
|
|