I need help with WXPerl logging.  I'm converting a command-line
program, a finance application, which routinely writes a fair amount of
information to STDOUT - account names, totals, counts etc.  I want to
gather that material up in a Wx::Logwindow, so that the user can scroll
it up and down, copy stuff from it and so forth.  But I don't know how
to apply the information in the "Logging overview", especially the part
where, referring to wxLogMessage: "They also appear in a message box by
default (but it can be changed)"; I don't want any of my output
appearing in message boxes, but it seems that in order to do that I
need to subclass wxLog, which would involve C++ programming.

A test program (based on one of the tutorial examples)

#!/usr/bin/perl

use strict;
use warnings;
use 5.016;
use Wx;

package MyFrame;
    
use base 'Wx::Frame';
use Wx::Event qw(EVT_BUTTON);

sub new {
    my $ref = shift;
    my $self = $ref->SUPER::new( undef,           # parent window
                                 -1,              # ID -1 means any
                                 'wxPerl rules',  # title
                                 [-1, -1],        # default position
                                300, 200],      # size
                                 );
    my $panel = Wx::Panel->new( $self,            # parent window
                                -1,               # ID
                                );
    my $button = Wx::Button->new( $panel,         # parent window
                                  -1,             # ID
                                  'Click me!',    # label
                                  [30, 20],       # position
                                  [-1, -1],       # default size
        );
    EVT_BUTTON( $self, $button, \&OnClick );

    return $self;
}

sub OnClick {
  my( $self, $event ) = @_;
  $self->SetTitle( 'Clicked' );
  my $log = Wx::LogWindow->new( $self, 'Title', 1, 1 );
  Wx::LogMessage('foo');
}


package MyApp;
    
use base 'Wx::App';
    
sub OnInit {
  my $frame = MyFrame->new;
  $frame->Show( 1 );
}
    
package main;
    
my $app = MyApp->new;
$app->MainLoop;

A log window appears, and "foo" appears in it, but it also appears in a
dialog box.  What do I have to do to lose the box?
-- 
-- 
Henry Law                    n e w s @ l a w s h o u s e . o r g
Manchester, England            

Reply via email to