in reply to Re^2: Perl/Tk application rendering HTML?
in thread Perl/Tk application rendering HTML?
use Tk; require Tk::Web; # require Tk::ErrorDialog; require Tk::LabEntry; require URI::URL; require Tk::Menubar; my $pwd = `pwd`; chomp($pwd); my $urltxt; my $showlink; my $mw = MainWindow->new(); my $mb = $mw->menu; my $fm = $mb->Menubutton(-text => 'File', -underline => 0); my $em = $mb->Menubutton(-text => 'Edit', -underline => 0); my $vm = $mb->Menubutton(-text => 'View', -underline => 0); my $hm = $mb->Menubutton(-text => 'Help', -underline => 0); my $but = $mw->Frame->pack(-fill => 'x'); my $w = Tk::Web->new($mw,-showlink => sub { $showlink = shift }, -ur +lcommand => sub { $urltxt = shift} ); my $e = $mw->LabEntry(-label => 'Location:',-labelPack => [-side => +'left',-anchor => 'e'],-textvariable => \$urltxt )->pack(-fill => 'x' +); $e->bind('<Return>',[$w,'url',Tk::Ev(['get'])]); $w->{'-header'} = {'Accept' => join(',','text/html', 'text/plain', 'im +age/gif', 'image/x-xbitmap', 'image/x-pixmap +', '*/*'), 'User-Agent' => 'tkweb/.xx'}; $w->pack(-expand => 1, -fill => 'both'); $fm->command(-label => 'Open...',-underline => 0, -command => [$w,'Ope +n']); $fm->command(-label => 'Save as...',-underline => 0, -command => [$w,' +SaveAs']); $fm->command(-label => 'Exit',-underline => 1, -command => [$mw,'destr +oy']); $vm->command(-label => 'Reload',-underline => 0, -command => [$w,'Relo +ad']); $vm->command(-label => 'Source...',-underline => 0, -command => [$w,'S +howSource']); $vm->command(-label => 'HTML...',-underline => 0, -command => [$w,'Sho +wHTML']); $but->Button(-text => 'Back', -command => [$w,'Back'])->pack(-side => +'left'); $but->Button(-text => 'Forward', -command => [$w,'Forward'])->pack(-si +de => 'left'); $but->Button(-text => 'Home', -command => [$w,'Home'])->pack(-side => +'left'); $but->Button(-text => 'Reload', -command => [$w,'Reload'])->pack(-side + => 'left'); $but->Button(-text => 'Images', -command => [$w,'Images'], -state => ' +disabled')->pack(-side => 'left'); $but->Button(-text => 'Open', -command => [$w,'Open'])->pack(-side => +'left'); $but->Button(-text => 'Print', -command => [$w,'Print'])->pack(-side = +> 'left'); $but->Button(-text => 'Find', -command => [$w,'Find'])->pack(-side => +'left'); $but->Button(-text => 'Stop', -command => [$w,'Stop'])->pack(-side => +'left'); $mw->AddScrollbars($w); my $show = $mw->Frame(-label => 'URL : ',-labelPack => [-side => 'left +'])->pack(-fill => 'x'); $show->Label(-textvariable => \$showlink, -anchor => 'w')->pack(-fill +=> 'y',-anchor => 'w', -expand => 1, -side => 'left'); $show->Frame(-height => '3m', -width => '60m', -borderwidth => 3, -bac +kground => 'cyan', -relief => 'sunken') ->pack(-side => 'right', -padx => '3m'); my %args = (-scrollbars => 'w'); $mw->ConfigDefault(\%args); $mw->configure(%args); $w->url($ARGV[0]) if (@ARGV); $w->focus; MainLoop;
|
|---|