Yeah, Log::Log4perl::Appender::String isn't quite right for the job, and text widget doesn't support -textvariable

Here is a start, run with it :)

use strict; use warnings; use Tkx; use Log::Log4perl; Main( @ARGV ); exit( 0 ); sub Main { $Tkx::TRACE=64; Tkx::package_require('tile'); Tkx::ttk__setTheme('xpnative');#Tkx::tile__setTheme('xpnative'); my $logger = Log::Log4perl->get_logger; $logger ->level( $Log::Log4perl::INFO ); ## HA! my $appender = Log::Log4perl::Appender::String2->new; $logger->add_appender($appender); my $mw = Tkx::widget->new("."); my $t = $mw->new_text( -padx => 5, -pady => 5, #~ -textvariable => $appender->string_ref, # text doesn't have + textvariable, grr -background => "white", ); $t->g_pack; $appender->tktext( $t ); # text doesn't have textvariable, grr my $b = $mw->new_ttk__button( -text => 'Hello, world', -command => sub { $logger->info("hi"); #~ $mw->g_destroy; }, ); $b->g_pack; $b->configure(); $logger->info("it begins"); Tkx::MainLoop(); } BEGIN { #~ $INC{'TextTextVariable.pm'} = __FILE__; ## http://wiki.tcl.tk/1917# Text variable for text widget $INC{'Log/Log4perl/Appender/String2.pm'} = __FILE__; package Log::Log4perl::Appender::String2; use Log::Log4perl::Appender; our @ISA = qw(Log::Log4perl::Appender); ################################################## # Log dispatcher writing to a string buffer ################################################## ################################################## sub new { ################################################## my $proto = shift; my $class = ref $proto || $proto; my %params = @_; my $self = { name => "unknown name", string => "", %params, }; bless $self, $class; } ################################################## sub log { ################################################## #~ my $self = shift; #~ my %params = @_; # copied from Log::Log4perl::Appender::Str +ing, wtf my ($self, $p, $category, $level, $cache) = @_; my %params = %$p; if( my $status_text = $self->{tktext} ){ warn "wtf is wtf "; # text control has to be enabled to write to it. $status_text->configure(-state => "normal"); $status_text->insert("end", $params{message} ); $status_text->see("end"); # Don't want the user editing this... $status_text->configure(-state => "disabled"); eval { $status_text->update(); 1} or eval { Tkx::update(); + }; } else { $self->{string} .= $params{message}; } } ################################################## sub string { ################################################## my($self, $new) = @_; if(defined $new) { $self->{string} = $new; } return $self->{string}; } ################################################## sub tktext { ################################################## my($self, $new) = @_; if(defined $new) { $self->{tktext} = $new; } return $self->{tktext}; } ################################################## sub string_ref { ################################################## my($self ) = @_; return if $self->{tktext}; return \$self->{string}; } 1; }

In reply to Re: Log4perl and Tkx by Anonymous Monk
in thread Log4perl and Tkx by jellisii2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.