Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

How to get error/info/warning icons in perl /tk

by kapsule (Acolyte)
on Nov 03, 2008 at 11:20 UTC ( #721069=perlquestion: print w/replies, xml ) Need Help??
kapsule has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I am not able to get the same error/info/warning icons as i was getting using MessageBox widget.Only simple perl built-in bitmaps, i am able to get. Please help if anybody knows how to get those icons.
use strict; use warnings; use Tk; use Tk::Entry; our $mw = new MainWindow; our $main; my $new_label = $mw -> Label(-text=>"Enter any character", -foreground=>"red", -font => "verdanafont 10 bold") -> pack(-side=>"top"); my $ent=$mw->Entry()->pack(); my $press = $mw -> Button(-text=>"Press Me", -command =>\&PressMe, -font => "verdanafont 10 bold") -> pack(-side=>"left",-padx=>"5", -ipadx=>"5"); MainLoop; sub PressMe { my $val = $ent->get(); if ($val =~ m/[a-zA-Z0-9]/) { #my $response=$mw -> messageBox(-type=>"ok", -message=>"al +phanumeric entered",-icon=>"info",-title=> "info!!"); if (!Exists($main)) { $main = $mw->Toplevel; $main->geometry("250x100"); $main->transient($mw); $main->protocol('WM_DELETE_WINDOW' => sub {$main->destroy( +);}); #$main->Photo('-format'=>'jpeg', -file => "\@C:\\warn.jpg" +); #my $l=$main->Label(-image=>'hi')->pack; my $l = $main->Label(-bitmap=>"info")->pack(-side=>"left") +; my $ll=$main->Label(-text=>"Alpha numeric entered !")->pac +k(); } else { $main->deiconify(); $main->raise(); } } return; }

Replies are listed 'Best First'.
Re: How to get error/info/warning icons in perl /tk
by zentara (Archbishop) on Nov 03, 2008 at 14:01 UTC
    Dig the bitmaps out of the Tk module source directory, under pTk/bitmaps, or make your own. Also see zicons-Tk-Icon-Selector
    #!/usr/bin/perl use warnings; use strict; use Tk; # from perldoc 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. my $mw = tkinit; $mw->fontCreate('big', -family=>'arial', -weight=>'bold', -size=>int(-18*18/14)); 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, -font => 'big', -type => 'OK' ); }

    I'm not really a human, but I play one on earth Remember How Lucky You Are
      I think MessageBox uses the native operating systems messagebox/icons
Re: How to get error/info/warning icons in perl /tk
by Anonymous Monk on Nov 04, 2008 at 03:43 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://721069]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2018-04-25 09:50 GMT
Find Nodes?
    Voting Booth?