If you don't mind using the Win32::GUI module instead of Tk, it has a sub package called AxWindow. This allows you to use ActiveX controls in your window, which includes a web browser.
Here is some sample code:
#!perl
use strict;
use warnings;
use Win32::GUI qw();
use Win32::GUI::AxWindow;
# Main Window
my $Window = Win32::GUI::Window->new(
-name => 'Window',
-text => 'Win32::GUI::AxWindow Web Browser',
-pos => [100, 100],
-size => [640, 480],
);
# Add a WebBrowser AxtiveX
my $Browser = Win32::GUI::AxWindow->new(
-parent => $Window,
-name => 'Browser',
-control => 'Shell.Explorer',
-pos => [0, 0],
-size => [640, 480],
);
# Register some event
$Browser->RegisterEvent(
StatusTextChange => sub {
my $self = shift;
my $eventid = shift;
print 'Event : ', @_, "\n";
}
);
# Call Method
$Browser->CallMethod('Navigate', 'http://www.perlmonks.org/');
# Event loop
$Window->Show();
Win32::GUI::Dialog();
# Main window event handler
sub Window_Resize {
my($width, $height) = ($Window->GetClientRect)[2..3];
$Browser->Move (0, 0);
$Browser->Resize($width, $height);
return 1;
}
__END__
|