Help with WxPerl logging

[email protected] (Henry Law) Sat, 18 Jun 2022 22:33:29 +0100
Newsgroups perl.wxperl.users
Message-ID <[email protected]>
--=-cGlCL9jHfH6LCJDcKTEg
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit

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            

--=-cGlCL9jHfH6LCJDcKTEg
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<html dir=3D"ltr"><head></head><body style=3D"text-align:left; direction:lt=
r;"><div>I need help with WXPerl logging.&nbsp;&nbsp;I'm converting a comma=
nd-line program, a finance application, which routinely writes a fair amoun=
t of information to STDOUT - account names, totals, counts etc.&nbsp;&nbsp;=
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.&nbsp;&nbsp;But I do=
n'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 appe=
aring in message boxes, but it seems that in order to do that I need to sub=
class wxLog, which would involve C++ programming.</div><div><br></div><div>=
A test program (based on one of the tutorial examples)</div><div><br></div>=
<div>#!/usr/bin/perl</div><div><br></div><div>use strict;</div><div>use war=
nings;</div><div>use 5.016;</div><div>use Wx;</div><div><br></div><div>pack=
age MyFrame;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;</div><div>use base 'Wx::Fra=
me';</div><div>use Wx::Event qw(EVT_BUTTON);</div><div><br></div><div>sub n=
ew {</div><div>&nbsp;&nbsp;&nbsp;&nbsp;my $ref =3D shift;</div><div>&nbsp;&=
nbsp;&nbsp;&nbsp;my $self =3D $ref-&gt;SUPER::new( undef,&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# parent window</div><div>&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-1, &nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp;# ID -1 means any</div><div>&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;'wxPerl rules', &nbsp;# title</div><div>&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[-1, -1], &nbsp; &nbsp; &nbsp; &nbsp;=
# default position</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;300,=
 200], &nbsp; &nbsp;&nbsp;&nbsp;# size</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;);</div><div><br></div><div>&nbsp;&nbsp;&nbsp;&nbsp;m=
y $panel =3D Wx::Panel-&gt;new( $self, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# parent window</div><div>&nbsp;&nbsp;&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nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;'Click me!',&nbsp;&nbsp;&nbsp;&nbsp;# label</div><div>&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[30, 20],&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;# position</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;[-1, -1],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# de=
fault size</div><div>	);</div><div>&nbsp;&nbsp;&nbsp;&nbsp;EVT_BUTTON( $sel=
f, $button, \&amp;OnClick );</div><div><br></div><div>&nbsp;&nbsp;&nbsp;&nb=
sp;return $self;</div><div>}</div><div><br></div><div>sub OnClick {</div><d=
iv>&nbsp; my( $self, $event ) =3D @_;</div><div>&nbsp; $self-&gt;SetTitle( =
'Clicked' );</div><div>&nbsp; my $log =3D Wx::LogWindow-&gt;new( $self, 'Ti=
tle', 1, 1 );</div><div>&nbsp; Wx::LogMessage('foo');</div><div>}</div><div=
><br></div><div><br></div><div>package MyApp;</div><div>&nbsp;&nbsp;&nbsp;&=
nbsp;</div><div>use base 'Wx::App';</div><div>&nbsp;&nbsp;&nbsp;&nbsp;</div=
><div>sub OnInit {</div><div>&nbsp; my $frame =3D MyFrame-&gt;new;</div><di=
v>&nbsp; $frame-&gt;Show( 1 );</div><div>}</div><div>&nbsp;&nbsp;&nbsp;&nbs=
p;</div><div>package main;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;</div><div>my =
$app =3D MyApp-&gt;new;</div><div>$app-&gt;MainLoop;</div><div><br></div><d=
iv>A log window appears, and "foo" appears in it, but it also appears in a =
dialog box.&nbsp;&nbsp;What do I have to do to lose the box?</div><div><spa=
n><pre>-- <br></pre><div style=3D"width: 71ch;">--&nbsp;</div><div style=3D=
"width: 71ch;">Henry Law&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n e w =
s @ l a w s h o u s e . o r g</div><div style=3D"width: 71ch;">Manchester, =
England &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div></span></div></body>=
</html>

--=-cGlCL9jHfH6LCJDcKTEg--