| 1 |
#!/usr/bin/env perl |
| 2 |
|
| 3 |
# Demonstrate how to use Dialog to create and manipulate dialog objects. |
| 4 |
# [email protected] 95/06/14 |
| 5 |
|
| 6 |
|
| 7 |
require 5.002; |
| 8 |
use Tk; |
| 9 |
require Tk::Dialog; |
| 10 |
use strict; |
| 11 |
|
| 12 |
my $MW = MainWindow->new; |
| 13 |
my $but = $MW->Button(-text => 'Quit', -command => \&exit); |
| 14 |
$but->pack; |
| 15 |
my $bitmaps = Tk->findINC("demos/images"); |
| 16 |
|
| 17 |
my $D1 = $MW->Dialog( |
| 18 |
-title => 'Dialog Example 1', |
| 19 |
-text => '', |
| 20 |
-bitmap => "\@${bitmaps}/noletters", |
| 21 |
-default_button => '3', |
| 22 |
-buttons => ['OK', '2', '3'], |
| 23 |
); |
| 24 |
my $D2 = $MW->Dialog( |
| 25 |
-title => 'Dialog Example 2', |
| 26 |
-text => 'Frogs lacking lipophores are blue!', |
| 27 |
-bitmap => 'warning' |
| 28 |
); |
| 29 |
|
| 30 |
$D1->configure( |
| 31 |
-wraplength => '6i', |
| 32 |
-justify => 'right', |
| 33 |
-text => 'Crest has been shown to be an effective ' . |
| 34 |
'decay-preventive dentifrice that can be of significant ' . |
| 35 |
'value when used in a conscientiously applied program ' . |
| 36 |
'of oral hygiene and regular professional care.', |
| 37 |
); |
| 38 |
$D1->configure(-bg => 'yellow', -fg => 'blue'); |
| 39 |
print "Selected button = ", $D1->Show, ".\n"; |
| 40 |
|
| 41 |
$D2->Show('-global'); |
| 42 |
|
| 43 |
$D2->configure(-text => 'Change message text.'); |
| 44 |
$D2->Show; |
| 45 |
$D2->configure(-text => 'New font.', -font => '-*-helvetica-bold-r-*-*-*-240-*-*-*-*-*-*'); |
| 46 |
$D2->Show; |
| 47 |
$D2->configure(-text => 'New color.', -foreground => 'cyan'); |
| 48 |
$D2->Show; |
| 49 |
|
| 50 |
$D2->configure(-text => 'New bitmap and background color.'); |
| 51 |
$D2->configure(-bitmap => "\@$bitmaps/flagup", -background => 'red'); |
| 52 |
Show $D2; |
| 53 |
|
| 54 |
$D2->configure(-bitmap => undef, -bg => ($D2->configure(-bg))[3]); |
| 55 |
$D2->Subwidget('message')->configure( |
| 56 |
-text => 'Now remove the bitmap ...', |
| 57 |
-wraplength => '3i', |
| 58 |
); |
| 59 |
$D2->Show; |
| 60 |
|
| 61 |
$D2->configure(-bitmap => "\@$bitmaps/flagdown"); |
| 62 |
$D2->Subwidget('message')->configure( |
| 63 |
-text => 'and restore Flagdown!', |
| 64 |
-justify => 'center', |
| 65 |
); |
| 66 |
$D2->Show; |
| 67 |
|
| 68 |
MainLoop; |