Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Think about Loose Coupling
 
PerlMonks

WxBrowser - a wxPerl HTML Browser

by crazyinsomniac (Prior)
 | Log in | Create a new user | The Monastery Gates | Super Search | 
 | Seekers of Perl Wisdom | Meditations | PerlMonks Discussion | 
 | Obfuscation | Reviews | Cool Uses For Perl | Perl News | Q&A | Tutorials | 
 | Poetry | Recent Threads | Newest Nodes | Donate | What's New | 

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++
        } qw/ GOTEXT GOBUTTON HTML ABOUT QUIT GOTEXT/;

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


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

    $this->GOOEY();
    $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 PerlMonks.org.
This program is released under the same terms as perl itself
(if you don't know what that means, visit perl.com )
",
        "About WxBrowser", wxOK|wxICON_INFORMATION, $this );
}

sub OnQuit {
    my( $this, $event ) = @_;
    
    $this->Close(1);
}


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});

    $html->LoadPage($text->GetValue());

    return();
}

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( ###
                        $parent,
                        $ID_{HTML},
                        wxDefaultPosition,
                        wxDefaultSize,
                    );



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



    $html->SetPage('<H1><a href="http://perlmonk.org/~grinder"><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
+</font>!</a></H1>');

    $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},
            "http://perlmonk.org/#jc+wrocks!",
            wxDefaultPosition,
#            [460,-1],
            wxDefaultSize,
            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,
            $ID_{GOBUTTON},
            "GO",
            wxDefaultPosition,
            [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();
    $frame->Show(1);
    1;
}


package main;

my $Browser = new WxBrowser();
$Browser->MainLoop();

__END__

=pod

Run the program!

=cut

Comment on WxBrowser - a wxPerl HTML Browser
Download Code

Back to Code Catacombs

Login:
Password
remember me
What's my password?
Create A New User

Node Status?
node history
Node Type: sourcecode [id://164341]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (24)
ikegami
GrandFather
Limbic~Region
CountZero
marto
jmcnamara
toolic
holli
Gavin
atcroft
kennethk
thezip
Eyck
Marshall
socketdave
superfrink
crashtest
pemungkah
ssandv
Rodster001
CColin
MikeDexter
johnvk
im2
As of 2010-02-09 21:37 GMT
Sections?
The Monastery Gates
Seekers of Perl Wisdom
Meditations
PerlMonks Discussion
Categorized Q&A
Tutorials
Obfuscated Code
Perl Poetry
Cool Uses for Perl
Perl News
Information?
PerlMonks FAQ
Guide to the Monastery
What's New at PerlMonks
Voting/Experience System
Tutorials
Reviews
Library
Perl FAQs
Other Info Sources
Find Nodes?
Nodes You Wrote
Super Search
List Nodes By Users
Newest Nodes
Recently Active Threads
Selected Best Nodes
Best Nodes
Worst Nodes
Saints in our Book
Leftovers?
The St. Larry Wall Shrine
Offering Plate
Awards
Craft
Snippets Section
Code Catacombs
Quests
Editor Requests
Buy PerlMonks Gear
PerlMonks Merchandise
Planet Perl
Perlsphere
Use Perl
Perl.com
Perl 5 Wiki
Perl Jobs
Perl Mongers
Perl Directory
Perl documentation
CPAN
Random Node
Voting Booth?

What level of existential comfort do you require?

Palace
Executive suite at the best hotel
Regular hotel in a decent part of town
Motel
Boarding house
Sleeping Bag on Couch in Basement
Any port in a storm
Camping under the freeway overpass
Jail
Other

Results (281 votes), past polls