problem with right justified text

"Hidasi Zsolt" <[email protected]>
Newsgroups gmane.comp.lang.perl.tk
Message-ID <[email protected]>
Dear Everybody,

I'm incapable of solving the scrollbar problem with right justified text... I spent a lot of time to do several experiments,
with different approaches, but there isn't any usable code. My aim is to make a right to left writing text widget, which is none wrapping, but I need the scrollbar, Lord...

Please help if somebody has experiences in this subject.

Any suggestion will be appreciated.

here is the problem:

use Tk;
use Tk::Text;
use strict;

my $mw = MainWindow->new;
my $t = $mw->Scrolled('Text', -scrollbars=> 'se', -height=> 5, -background =>'SystemWindow', -wrap => 'none')->pack(-side=>'bottom', -fill=> 'both', -expand=> '1');
$t->tagConfigure('right', -justify => 'right');
$t->insert('end',"This is a right justified, none wrapping text.\n",'right');
$t->insert('end','Try to type some text over the left edge of the window here: ','right');
$t->focus;
MainLoop;

And here is an attempt with canvas, but I would prefered the text widget.

use Tk;
use Tk::Text;
require Tk::Adjuster;
use strict;

my $mw = MainWindow->new;

my $t2 = $mw->Scrolled('Text', -scrollbars=> 'ose', -height=> 5, -background =>'SystemButtonFace', -wrap => 'none')->pack(-side=>'bottom', -fill=> 'both', -expand=> '1');
my $t1 = $mw->Scrolled('Text', -scrollbars=> 'ose', -height=> 5, -background =>'SystemWindow', -wrap => 'none')->pack(-side=>'bottom', -fill=> 'both', -expand=> '1');

$t2->tagConfigure('right', -justify => 'right');
$mw->Adjuster->packAfter($t2, -side => 'bottom', -fill => 'both');
$t1->focus;
$t1->bind('<KeyPress>' => sub {
    my @revlines;
    my $str = $t1->get('1.0', 'end');
    my @lines = split(/\n/,$str);
    foreach (@lines) {
        my $revstr = reverse $_;
        @revlines = (@revlines, $revstr);
    }
    $t2->delete('1.0','end');
    foreach (@revlines) {
        $t2->insert('end', "$_\n", 'right');
    }
    my $idx1 = $t1->index('insert');
    $t2->SetCursor($idx1);});
MainLoop;

With the Best:

Zsolt

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.