Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

WxBrowser - a wxPerl HTML Browser

by crazyinsomniac (Prior)
on May 06, 2002 at 14:42 UTC ( #164341=sourcecode: print w/replies, xml ) Need Help??
Category: GUI Programming
Author/Contact Info /tell crazyinsomniac
Description: A crude HTML Browser written using wxPerl. More of a minimalistic demo than anything. Nice layout IMO (a hint of things to come).

If you want the GOBAR at the bottom, just ## switch these two lines, the wxBOTTOM or wxTOP don't matter
$sizer1->Add( $sizer3, 0, wxGROW|wxTOP, 0 );
$sizer1->Add( $sizer2, 1, wxGROW|wxALIGN_CENTER_VERTICAL, 0 );

#!/usr/bin/perl -w

package WxBrowser::GUI;
use strict;
use Wx qw/:everything/;
use Wx::Html;
use base qw(Wx::Frame);

use Wx::Event qw( EVT_BUTTON EVT_MENU);

use vars qw/ %ID_ $I/;

%ID_ = map { $_ => 1000 + int(rand 30) + $I++

sub new {
    my( $class ) = shift;
    my( $this ) = $class->SUPER::new(
                    undef, -1,
                    "WxBrowser - a wxPerl HTML Browser ",
                    wxDEFAULT_FRAME_STYLE| wxCLIP_CHILDREN,

    $this->CreateStatusBar( 2 );
    $this->SetStatusText( "Welcome to WxBrowser!", 1);

    $this->SetMenuBar( MENUU($this) );

    EVT_BUTTON( $this, $ID_{GOBUTTON}, \&GONOW );
    EVT_MENU( $this, $ID_{ABOUT}, \&OnAbout );
    EVT_MENU( $this, $ID_{QUIT}, \&OnQuit );

    return $this;

sub OnAbout {
    my( $this, $event ) = @_;
    Wx::MessageBox( "Welcome to WxBrowser 1.0

WxBrowser is a crude browser created as a demo of wxPerl
Has basic support for html (probably html 1.0 or 2.0)
That means, no cookies, no images, no forms, bad tables ;)

(C)opyright CrazyInsomniac of
This program is released under the same terms as perl itself
(if you don't know what that means, visit )
        "About WxBrowser", wxOK|wxICON_INFORMATION, $this );

sub OnQuit {
    my( $this, $event ) = @_;

sub MENUU {
    my( $bar ) = Wx::MenuBar->new();
    my( $filemenu ) = Wx::Menu->new();
    $filemenu->Append( $ID_{ABOUT}, "About", "Find Out Who Created WxB
+rowser" );
    $filemenu->Append( $ID_{QUIT}, "Quit", "Exit this application" );
    $bar->Append( $filemenu, "File" );
    return $bar;

sub GONOW {
    my ($this, $event) = @_;
    my $html = $this->FindWindow($ID_{HTML});
    my $text = $this->FindWindow($ID_{GOTEXT});



sub GOOEY{
    my $parent = shift;
    my( $sizer1 ) = Wx::BoxSizer->new( wxVERTICAL );
    my( $sizer2 ) = Wx::BoxSizer->new( wxVERTICAL );

    my( $htmlsizer ) = Wx::BoxSizer->new( wxVERTICAL ); ###

    my( $html ) = Wx::HtmlWindow->new( ###

    $html->SetRelatedFrame($parent, "WxBrowser: %s");

    $html->SetPage('<H1><a href=""><font c
+olor="#be2076">W</font><font color="#b15088">a</font><font color="#a2
+8999">v</font><font color="#93bea9">e</font> <font color="#83e3b9">i<
+/font><font color="#73efc7">t</font> <font color="#63e0d3">h</font><f
+ont color="#54b9dd">i</font><font color="#4583e5">g</font><font color
+="#374aeb">h</font><font color="#2a1cef">,</font><P><font color="#1e0
+2ef">l</font><font color="#1404ee">e</font><font color="#0c08e9">t</f
+ont> <font color="#060de3">t</font><font color="#0214da">h</font><fon
+t color="#001bcf">a</font><font color="#0024c2">t</font> <font color=
+"#092eb3">f</font><font color="#1e38a4">r</font><font color="#3d4393"
+>e</font><font color="#624f82">a</font><font color="#8a5b70">k</font>
+<P><font color="#af685f">f</font><font color="#cf754e">l</font><font 
+color="#e5813e">a</font><font color="#ef8e2f">g</font> <font color="#
+ec9a22">f</font><font color="#dda617">l</font><font color="#c2b20d">y

    $htmlsizer->AddWindow( $html, 1, wxALIGN_CENTRE|wxGROW, 0 );###

    $sizer2->Add($htmlsizer, 1, wxGROW|wxALIGN_CENTER_VERTICAL, 0 );##

    my( $sizer3 ) = Wx::BoxSizer->new( wxHORIZONTAL );
    my( $text ) = Wx::TextCtrl->new( $parent, $ID_{GOTEXT},
#            [460,-1],
            wxGROW # I don't even know if this works here
    $sizer3->AddWindow( $text, 1, wxGROW|wxALIGN_CENTER_HORIZONTAL, 0 

    my( $item9 ) = Wx::Button->new( $parent,
            [50,20], 0
    $sizer3->AddWindow( $item9, 0, wxALIGN_RIGHT|wxALL, 0 );

## switch these two lines, the wxBOTTOM  or wxTOP don't matter
    $sizer1->Add( $sizer3, 0, wxGROW|wxTOP, 0 );
    $sizer1->Add( $sizer2, 1, wxGROW|wxALIGN_CENTER_VERTICAL, 0 );

    $parent->SetAutoLayout( 1 );
    $parent->SetSizer( $sizer1 );

package WxBrowser;

use strict;
use base qw(Wx::App);
use Wx qw(:everything);

sub OnInit {
    my( $this ) = @_;

    my( $frame ) = new WxBrowser::GUI();

package main;

my $Browser = new WxBrowser();



Run the program!

Replies are listed 'Best First'.
Re: WxBrowser - a wxPerl HTML Browser
by ka1958 (Initiate) on Mar 09, 2010 at 12:53 UTC
    This is excelent. Thanks you for posting. Will be an awesome foundation for a full featured perl web browser I intend to write. Cant believe it took me so long to find it. ^_^ Cheers, Kyle.
Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://164341]
[ambrus]: ah, it's one of thos
[Eily]: what, there's a difference between proof of concept and production?
[LanX]: 20 years ago traders were complaining about the latency of the trading system...
[ambrus]: I'm currently in the process of rewriting my proof of concept programs. They sort of developped organically as I was experimenting, so now I've got an ugly mess of multiple programs and one-liners held together by nothing. I'll have to rewrite them to som
[ambrus]: ething that's both cleanly organized and mostly automated.
LanX in train, bad connection
[Corion]: ambrus: Yeah - we're in that situation too, except that there is no time to do the reorganizing :-/
[LanX]: ... so my boss started a project with the newest sun servers and invited the traders to come on weekend to test it... and they were so pleased, that they forced him to keep it in production...
[ambrus]: Corion: sure, this is the long-term plan. The short term is that I have to run this ungodly mess to get results from the new input data today.

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (16)
As of 2017-03-29 11:49 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (350 votes). Check out past polls.