home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2004 July / APC0407D2.iso / workshop / apache / files / ActivePerl-5.6.1.638-MSWin32-x86.msi / _1ba14717ef2ba9754ce614fb60d752fe < prev    next >
Encoding:
Text File  |  2004-04-13  |  1.7 KB  |  53 lines

  1. # radio.pl
  2.  
  3. use vars qw/$TOP/;
  4.  
  5. sub radio {
  6.  
  7.     # Create a top-level window that displays a bunch of radio buttons.
  8.  
  9.     my($demo) = @_;
  10.     $TOP = $MW->WidgetDemo(
  11.         -name     => $demo,
  12.         -text     => ['Two groups of radiobuttons are displayed below.  If you click on a button then the button will become selected exclusively among all the buttons in its group.  A Perl variable is associated with each group to indicate which of the group\'s buttons is selected.  Click the "See Variables" button to see the current values of the variables.', qw/-wraplength 5i/],
  13.         -title    => 'Radiobutton Demonstration',
  14.         -iconname => 'radio',
  15.     );
  16.  
  17.     my $var = $TOP->Button(
  18.         -text    => 'See Variables',
  19.         -command => [\&see_vars, $TOP, [
  20.                                       ['point size', \$POINT_SIZE],
  21.                                       ['color',      \$COLOR],
  22.                       ]
  23.              ],
  24.     );
  25.     $var->pack(qw/-side bottom -expand 1/);
  26.  
  27.     my @pl = qw/-side left -expand 1 -padx .5c -pady .5c/;
  28.     my $left = $TOP->Frame->pack(@pl);
  29.     my $right = $TOP->Frame->pack(@pl);
  30.  
  31.     @pl = qw/-side top -pady 2 -anchor w/;
  32.     foreach my $p (10, 12, 18, 24) {
  33.     $left->Radiobutton(
  34.             -text     => "Point Size $p",
  35.             -variable => \$POINT_SIZE,
  36.             -relief   => 'flat',
  37.             -value    => $p,
  38.         )->pack(@pl);
  39.     }
  40.  
  41.     foreach my $c (qw/Red Green Blue Yellow Orange Purple/) {
  42.     $right->Radiobutton(
  43.             -text     => $c,
  44.             -variable => \$COLOR,
  45.             -relief   => 'flat',
  46.             -value    => lc($c),
  47.         )->pack(@pl);
  48.     }
  49.  
  50. } # end radio
  51.  
  52. 1;
  53.