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. 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. =
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 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> </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> my $ref =3D shift;</div><div> &=
nbsp; my $self =3D $ref->SUPER::new( undef, =
# parent window</div><div>&=
nbsp; &nbs=
p; &=
nbsp; -1, &nb=
sp; # ID -1 means any</div><div>  =
; &n=
bsp;  =
; 'wxPerl rules', # title</div><div> &nbs=
p; &=
nbsp; &nbs=
p; [-1, -1], =
# default position</div><div> &nbs=
p; &=
nbsp; 300,=
200], # size</div><div> &n=
bsp;  =
; &n=
bsp; );</div><div><br></div><div> m=
y $panel =3D Wx::Panel->new( $self, =
# parent window</div><div> &=
nbsp; &nbs=
p; &=
nbsp; -1, &=
nbsp; # ID</div><div> &=
nbsp; &nbs=
p; &=
nbsp; );</div><div> my $button =3D =
Wx::Button->new( $panel, =
# parent window</div><div> &=
nbsp; &nbs=
p; &=
nbsp; -1, &=
nbsp; # ID</div><div> &=
nbsp; &nbs=
p; &=
nbsp; 'Click me!', # label</div><div> &nbs=
p; &=
nbsp; &nbs=
p; [30, 20], &nbs=
p; # position</div><div> &nbs=
p; &=
nbsp; &nbs=
p; [-1, -1], # de=
fault size</div><div> );</div><div> EVT_BUTTON( $sel=
f, $button, \&OnClick );</div><div><br></div><div> &nb=
sp;return $self;</div><div>}</div><div><br></div><div>sub OnClick {</div><d=
iv> my( $self, $event ) =3D @_;</div><div> $self->SetTitle( =
'Clicked' );</div><div> my $log =3D Wx::LogWindow->new( $self, 'Ti=
tle', 1, 1 );</div><div> Wx::LogMessage('foo');</div><div>}</div><div=
><br></div><div><br></div><div>package MyApp;</div><div> &=
nbsp;</div><div>use base 'Wx::App';</div><div> </div=
><div>sub OnInit {</div><div> my $frame =3D MyFrame->new;</div><di=
v> $frame->Show( 1 );</div><div>}</div><div> &nbs=
p;</div><div>package main;</div><div> </div><div>my =
$app =3D MyApp->new;</div><div>$app->MainLoop;</div><div><br></div><d=
iv>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?</div><div><spa=
n><pre>-- <br></pre><div style=3D"width: 71ch;">-- </div><div style=3D=
"width: 71ch;">Henry Law &nb=
sp; n e w =
s @ l a w s h o u s e . o r g</div><div style=3D"width: 71ch;">Manchester, =
England </div></span></div></body>=
</html>
--=-cGlCL9jHfH6LCJDcKTEg--