Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Does anyone know if an Internet Explorer widget exists for Perl/TK? I would like to incorporate a frame that loads data from a webpage (Windows platform), but don't want to go into writing a web browser widget. If one doesn't exist, any ideas on what it would take to create one?

Replies are listed 'Best First'.
Re: Internet Explorer widget for Tk?
by BrowserUk (Patriarch) on Jun 09, 2010 at 12:55 UTC
    I would like to incorporate a frame that loads data from a webpage (Windows platform), but don't want to go into writing a web browser widget. If one doesn't exist, any ideas on what it would take to create one?

    You appear to be asking for a Tk widget that renders HTML?

    If so, what your are asking for is a Tk Web Browser.

    With all the complexities of interpreting multiple standards of HTML(1,2,3,4,5), XHTML, XML, css (1, 2, 3), Javascript (of various flavours), Plug-ins (of a multitude of flavours); not to mention handling Bad HTML, XML, css etc.

    In a nutshell, the answer to "what it would take to create one?" is: $millions.

    There is an MS Web Browser control, that can be embedded within other application (C, C++, C#', VB), and theoretically could be embedded within a Perl application via Win32::API and/or Win32::OLE. But trust me, as someone who wasted many tens of hours trying to do useful things with this, it is a hell of a lot of work for very little reward, due to the significant limitations of both the interface and IE. The control is essentially IE-in-a-window-via-OLE. And that's before you try and integrate it with Tk, which is a world of undocumented magic all of its own.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Internet Explorer widget for Tk?
by stefbv (Priest) on Jun 09, 2010 at 13:03 UTC
      I need to support JavaScript....

        No one stops you from using one of the Javascript engines available at CPAN and merge them with Tk::HTML into something like Tk::HTML::JSenabled.

        You could also make that a job offer ...

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: Internet Explorer widget for Tk?
by kejohm (Hermit) on Jun 10, 2010 at 00:16 UTC

    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__