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 / _90a4dc85fedd7e32a3bc1ea028ab7a9f < prev    next >
Encoding:
Text File  |  2004-04-13  |  3.6 KB  |  80 lines

  1.  
  2.  
  3. sub mkRadio {
  4.  
  5.     # Create a top-level window that displays a bunch of radio buttons.
  6.  
  7.     $mkRadio->destroy if Exists($mkRadio);
  8.     $mkRadio = $top->Toplevel();
  9.     my $w = $mkRadio;
  10.     dpos $w;
  11.     $w->title('Radiobutton Demonstration');
  12.     $w->iconname('Radiobuttons');
  13.     my $w_msg = $w->Message(-font => '-Adobe-times-medium-r-normal--*-180-*-*-*-*-*-*', -aspect => '300', -text =>
  14.                  'Two groups of radiobuttons are displayed below.  If you click on a button then the button ' .
  15.                  'will become selected exclusively among all the buttons in its group.  A Perl variable is ' .
  16.                  'associated with each group to indicate which of the group\'s buttons is selected.  Click the ' .
  17.                  '"See Variables" button to see the current values of the variables.  Click the "OK" button ' .
  18.                  'when you\'ve seen enough.');
  19.     my $w_frame = $w->Frame(-borderwidth => '10');
  20.     my $w_frame2 = $w->Frame();
  21.     my(@pl) = (-side => 'top');
  22.     $w_msg->pack(@pl);
  23.     $w_msg->pack(-side => 'top');
  24.     $w_frame->pack(@pl, -fill => 'x', -pady => '10');
  25.     $w_frame2->pack(@pl, -fill => 'x');
  26.  
  27.     my $w_frame_left = $w_frame->Frame();
  28.     my $w_frame_right = $w_frame->Frame();
  29.     @pl = (-side => 'left', -expand => 'yes');
  30.     $w_frame_left->pack(@pl);
  31.     $w_frame_right->pack(@pl);
  32.  
  33.     $size = '' if not defined $size;
  34.     $color = '' if not defined $color;
  35.     my $w_frame_left_b1 = $w_frame_left->Radiobutton(-text => 'Point Size 10', -variable => \$size, -relief => 'flat',
  36.                        -value => '10');
  37.     my $w_frame_left_b2 = $w_frame_left->Radiobutton(-text => 'Point Size 12', -variable => \$size, -relief => 'flat',
  38.                        -value => '12');
  39.     my $w_frame_left_b3 = $w_frame_left->Radiobutton(-text => 'Point Size 18', -variable => \$size, -relief => 'flat',
  40.                        -value => '18');
  41.     my $w_frame_left_b4 = $w_frame_left->Radiobutton(-text => 'Point Size 24', -variable => \$size, -relief => 'flat',
  42.                        -value => '24');
  43.     @pl = (-side => 'top', -pady => '2', -anchor => 'w');
  44.     $w_frame_left_b1->pack(@pl);
  45.     $w_frame_left_b2->pack(@pl);
  46.     $w_frame_left_b3->pack(@pl);
  47.     $w_frame_left_b4->pack(@pl);
  48.  
  49.     my $w_frame_right_b1 = $w_frame_right->Radiobutton(-text => 'Red', -variable => \$color, -relief => 'flat',
  50.                         -value => 'red');
  51.     my $w_frame_right_b2 = $w_frame_right->Radiobutton(-text => 'Green', -variable => \$color, -relief => 'flat',
  52.                         -value => 'green');
  53.     my $w_frame_right_b3 = $w_frame_right->Radiobutton(-text => 'Blue', -variable => \$color, -relief => 'flat',
  54.                         -value => 'blue');
  55.     my $w_frame_right_b4 = $w_frame_right->Radiobutton(-text => 'Yellow', -variable => \$color, -relief => 'flat',
  56.                         -value => 'yellow');
  57.     my $w_frame_right_b5 = $w_frame_right->Radiobutton(-text => 'Orange', -variable => \$color, -relief => 'flat',
  58.                         -value => 'orange');
  59.     my $w_frame_right_b6 = $w_frame_right->Radiobutton(-text => 'Purple', -variable => \$color, -relief => 'flat',
  60.                         -value => 'purple');
  61.     @pl = (-side => 'top', -pady => '2', -anchor => 'w');
  62.     $w_frame_right_b1->pack(@pl);
  63.     $w_frame_right_b2->pack(@pl);
  64.     $w_frame_right_b3->pack(@pl);
  65.     $w_frame_right_b4->pack(@pl);
  66.     $w_frame_right_b5->pack(@pl);
  67.     $w_frame_right_b6->pack(@pl);
  68.  
  69.     my $w_frame2_ok = $w_frame2->Button(-text => 'OK', -command => ['destroy', $w], -width => '12');
  70.     my $w_frame2_vars = $w_frame2->Button(-text => 'See Variables', -width => '12',
  71.                     -command => [\&showVars, $w, 'size', 'color']);
  72.     @pl = (-side => 'left', -expand => 'yes');
  73.     $w_frame2_ok->pack(@pl);
  74.     $w_frame2_vars->pack(@pl);
  75.  
  76. } # end mkRadio
  77.  
  78.  
  79. 1;
  80.