home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _1ff447edd97fd6ba650c341ce98a382b < prev    next >
Encoding:
Text File  |  2004-06-01  |  1.7 KB  |  60 lines

  1. # Notebook, selectable pages.
  2.  
  3. use Tk;
  4. use Tk::DialogBox;
  5. use Tk::NoteBook;
  6. use Tk::LabEntry;
  7.  
  8. my $name = "Rajappa Iyer";
  9. my $email = "rsi\@netcom.com";
  10. my $os = "Linux";
  11.  
  12. use vars qw($top);
  13.  
  14. $top = MainWindow->new;
  15. my $pb = $top->Button(-text => "Notebook", -command => \&donotebook);
  16. $pb->pack;
  17. MainLoop;
  18.  
  19.  
  20. my $f;
  21.  
  22. sub donotebook {
  23.     if (not defined $f) {
  24.     # The current example uses a DialogBox, but you could just
  25.     # as easily not use one... replace the following by
  26.     # $n = $top->NoteBook(-ipadx => 6, -ipady => 6);
  27.     # Of course, then you'd have to take care of the OK and Cancel
  28.     # buttons yourself. :-)
  29.     $f = $top->DialogBox(-title => "Personal Profile",
  30.                  -buttons => ["OK", "Cancel"]);
  31.     my $n = $f->add('NoteBook', -ipadx => 6, -ipady => 6);
  32.  
  33.     my $address_p = $n->add("address", -label => "Address", -underline => 0);
  34.     my $pref_p = $n->add("pref", -label => "Preferences", -underline => 0);
  35.  
  36.     $address_p->LabEntry(-label => "Name:             ",
  37.          -labelPack => [-side => "left", -anchor => "w"],
  38.          -width => 20,
  39.          -textvariable => \$name)->pack(-side => "top", -anchor => "nw");
  40.     $address_p->LabEntry(-label => "Email Address:",
  41.          -labelPack => [-side => "left", -anchor => "w"],
  42.          -width => 50,
  43.          -textvariable => \$email)->pack(-side => "top", -anchor => "nw");
  44.     $pref_p->LabEntry(-label => "Operating System:",
  45.          -labelPack => [-side => "left"],
  46.          -width => 15,
  47.          -textvariable => \$os)->pack(-side => "top", -anchor => "nw");
  48.     $n->pack(-expand => "yes",
  49.          -fill => "both",
  50.          -padx => 5, -pady => 5,
  51.          -side => "top");
  52.  
  53.     }
  54.     my $result = $f->Show;
  55.     if ($result =~ /OK/) {
  56.     print "name = $name, email = $email, os = $os\n";
  57.     }
  58. }
  59.  
  60.