home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Editores / Perl5 / perl / bin / tkweb < prev    next >
Encoding:
Text File  |  1997-08-10  |  3.1 KB  |  80 lines

  1. #!/usr/local/bin/perl -w
  2.  
  3. =head1 NAME
  4.  
  5. tkweb - rough and ready web browser
  6.  
  7. =head1 SYNOPSIS 
  8.  
  9. tkweb <url to view>
  10.  
  11. =head1 DESCRIPTION
  12.  
  13. Uses a derivative of Tk::Text and  libwww package to 
  14. produce a web browser.
  15.  
  16. =head1 BUGS
  17.  
  18. Lots...
  19.  
  20. =cut  
  21.  
  22. use Tk;
  23. require Tk::Web;
  24. # require Tk::ErrorDialog;
  25. require Tk::LabEntry;
  26. require URI::URL;
  27. require Tk::Menubar;
  28.  
  29. my $pwd = `pwd`;
  30. chomp($pwd);
  31.  
  32. my $urltxt;
  33. my $showlink;
  34.  
  35. my $mw = MainWindow->new();
  36. my $mb  = $mw->Menubar->pack(-fill => 'x');
  37. my $fm  = $mb->Menubutton(-text => 'File', -underline => 0)->pack(-side => 'left');; 
  38. my $em  = $mb->Menubutton(-text => 'Edit', -underline => 0)->pack(-side => 'left');; 
  39. my $vm  = $mb->Menubutton(-text => 'View', -underline => 0)->pack(-side => 'left');; 
  40. my $hm  = $mb->Menubutton(-text => 'Help', -underline => 0)->pack(-side => 'right');; 
  41. my $but = $mw->Frame->pack(-fill => 'x');
  42. my $w   = Tk::Web->new($mw,-showlink => sub { $showlink = shift }, -urlcommand => sub { $urltxt = shift} );
  43. my $e   = $mw->LabEntry(-label => 'Location:',-labelPack => [-side => 'left',-anchor => 'e'],-textvariable => \$urltxt )->pack(-fill => 'x');
  44.  
  45. $e->bind('<Return>',[$w,'url',Tk::Ev(['get'])]);
  46.  
  47. $w->{'-header'} = {'Accept' => join(',','text/html', 'text/plain', 'image/gif', 
  48.                                     'image/x-xbitmap', 'image/x-pixmap', '*/*'),
  49.            'User-Agent' => 'tkweb/.xx'};
  50.  
  51. $w->pack(-expand => 1, -fill => 'both');
  52. $fm->command(-label => 'Open...',-underline => 0, -command => [$w,'Open']); 
  53. $fm->command(-label => 'Save as...',-underline => 0, -command => [$w,'SaveAs']); 
  54. $fm->command(-label => 'Exit',-underline => 1, -command => [$mw,'destroy']); 
  55. $vm->command(-label => 'Reload',-underline => 0, -command => [$w,'Reload']); 
  56. $vm->command(-label => 'Source...',-underline => 0, -command => [$w,'ShowSource']); 
  57. $vm->command(-label => 'HTML...',-underline => 0, -command => [$w,'ShowHTML']); 
  58.  
  59. $but->Button(-text => 'Back', -command => [$w,'Back'])->pack(-side => 'left');
  60. $but->Button(-text => 'Forward', -command => [$w,'Forward'])->pack(-side => 'left');
  61. $but->Button(-text => 'Home', -command => [$w,'Home'])->pack(-side => 'left');
  62. $but->Button(-text => 'Reload', -command => [$w,'Reload'])->pack(-side => 'left');
  63. $but->Button(-text => 'Images', -command => [$w,'Images'], -state => 'disabled')->pack(-side => 'left');
  64. $but->Button(-text => 'Open', -command => [$w,'Open'])->pack(-side => 'left');
  65. $but->Button(-text => 'Print', -command => [$w,'Print'])->pack(-side => 'left');
  66. $but->Button(-text => 'Find', -command => [$w,'Find'])->pack(-side => 'left');
  67. $but->Button(-text => 'Stop', -command => [$w,'Stop'])->pack(-side => 'left');
  68. $mw->AddScrollbars($w);
  69. my $show = $mw->Frame(-label => 'URL : ',-labelPack => [-side => 'left'])->pack(-fill => 'x');
  70. $show->Label(-textvariable => \$showlink, -anchor => 'w')->pack(-fill => 'y',-anchor => 'w', -expand => 1, -side => 'left');
  71. $show->Frame(-height => '3m', -width => '60m', -borderwidth => 3, -background => 'cyan', -relief => 'sunken')
  72.              ->pack(-side => 'right', -padx => '3m');
  73. my %args = (-scrollbars => 'w');
  74. $mw->ConfigDefault(\%args);
  75. $mw->configure(%args);
  76. $w->url($ARGV[0]) if (@ARGV);
  77. $w->focus;
  78.  
  79. MainLoop;
  80.