wxperl + ubh
Gerard Lanois <[email protected]> Sat, 19 Apr 2003 12:11:39 -0700 (PDT)
| Newsgroups | gmane.network.ubh |
|---|---|
| Message-ID | <[email protected]> |
--- Tony Bierman <[email protected]> wrote: > p.s. I've been working with wxPerl API to wxWindows. #! /usr/bin/perl -w ###################################################################### package MenuID; use strict; my $mid = undef; sub new { if (defined $mid) { ++$$mid; return $mid; } else { my $class = shift; my $count = 0; $mid = bless \$count, $class; return $mid } } sub value { return $$mid; } ###################################################################### package UbhMaintApp; use strict; use vars qw(@ISA); @ISA=qw(Wx::App); sub OnInit { my $this = shift; my $frame = UbhMaintFrame->new( "ubh - Maintenance Tool", Wx::Point->new(50, 50), Wx::Size->new(1024, 600)); # Close app when this window is closed. $this->SetTopWindow($frame); $frame->Show(1); return 1; } ###################################################################### package UbhMaintFrame; use strict; use vars qw(@ISA); @ISA = qw(Wx::Frame); sub new { my $class = shift; # Window layout. my $self = $class->SUPER::new(undef, -1, $_[0], $_[1], $_[2]); # Display the tree and the text side-by-side. use Wx qw(:window); my $splitter = Wx::SplitterWindow->new($self, -1); use Wx qw(:textctrl wxDefaultPosition wxDefaultSize); $self->{_servers} = Wx::TextCtrl->new( $splitter, -1, '', wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxSIMPLE_BORDER); $self->{_newsgroups} = Wx::TextCtrl->new( $splitter, -1, '', wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxSIMPLE_BORDER); $splitter->SplitHorizontally($self->{_servers}, $self->{_newsgroups}); # Status bar. $self->{_statusbar} = $self->CreateStatusBar(1); # Pulldown menu bar. my $menu_bar = Wx::MenuBar->new(); $self->SetMenuBar($menu_bar); # File pulldown menu. my $file_menu = Wx::Menu->new; $menu_bar->Append($file_menu, "&File"); use Wx::Event qw(EVT_MENU); # File -> Exit my $ID_FILE_EXIT = MenuID->new->value; $file_menu->Append($ID_FILE_EXIT, "E&xit"); EVT_MENU($self, $ID_FILE_EXIT, \&OnFileExit); # Load data. $self->load; return $self; } sub load { my $self = shift; use Ubh::DB qw(connect get_servers get_newsgroups); my $dbh = connect; my $sth_servers = $dbh->prepare( "SELECT server_id,address,shortname,port,". "retries,delay,hdrsip,account,passwd,priority ". "active,bytelimit,bytecount ". "FROM servers ". "ORDER BY server_id"); $sth_servers->execute; while (my @cols = $sth_servers->fetchrow_array) { $self->{_servers}->AppendText( join( "\t", (map { defined $_ ? $_ : 'NULL' } @cols, "\n"))); } $sth_servers->finish; my $sth_newsgroups = $dbh->prepare( "SELECT newsgroup_id,name,output_dir,active ". "FROM newsgroups ". "ORDER BY newsgroup_id"); $sth_newsgroups->execute; while (my @cols = $sth_newsgroups->fetchrow_array) { $self->{_newsgroups}->AppendText(join "\t", (@cols, "\n")); } $sth_newsgroups->finish; $dbh->disconnect; } sub OnFileExit { my $self = shift; my $event = shift; $self->Close(1); } package main; use strict; my $app = UbhMaintApp->new(); $app->MainLoop(); ------------------------ Yahoo! Groups Sponsor ---------------------~--> Get 128 Bit SSL Encryption! http://us.click.yahoo.com/W7NydA/hdqFAA/VygGAA/IHFolB/TM ---------------------------------------------------------------------~-> To unsubscribe from this group, send an email to: [email protected] Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/