views:

262

answers:

1

Hi everybody.

I'm trying to create a GUI for a conversion program. I want to create a frame containing the log file, but I can't get it. I found some codes to make the entire window scrollable, but it's not what I want. I just want to scroll a frame containing a label with a chainging text-variable.

I've even tried the following code:

 $s = $parent->new_ttk__scrollbar(-orient => 'vertical', -command => [$frame, 'yview']);
 $frame->configure(-scrollcommand => [$s, 'set']);

but I get an error. Perl says that scrollcommand is not a recognised command.

I've posted a piece of my code on pastebin : http://pastebin.com/d22e5b134

A: 

Frame widgets aren't scrollable (i.e. they don't support the xview and yview methods). Use a text widget instead of a label in a frame. If you're lazy, use Tkx::Scrolled to do it for you. If you're using a label because you want it to be read-only, use Tkx::ROText instead. And while I'm promoting my own modules, use Tkx::FindBar for a nice Find-As-You-Type search interface.

use strict;
use warnings;

use Tkx;
use Tkx::FindBar;
use Tkx::ROText;
use Tkx::Scrolled;

my $mw = Tkx::widget->new('.');

my $text = $mw->new_tkx_Scrolled('tkx_ROText',
    -scrollbars => 'osoe',
    -wrap       => 'none',
);

my $findbar = $mw->new_tkx_FindBar(-textwidget => $text);

$findbar->add_bindings($mw,
    '<Control-f>'  => 'show',
    '<Escape>'     => 'hide',
    '<F3>'         => 'next',
    '<Control-F3>' => 'previous',
);

$text->g_pack(-fill => 'both', -expand => 1);

$findbar->g_pack(
    -after => $text,
    -side  => 'bottom',
    -fill  => 'x',
);

$findbar->hide();

open(my $fh, '<', __FILE__) or die;
$text->insert('end', do { local $/; <$fh> });
close $fh;

$mw->g_focus();
Tkx::MainLoop();
Michael Carman
Thanks for your help. I didn't know frames where not scrollable. I used a text widget with a fonction to disable, reable and write in everytime I need. I'm gonna take a look at your module as i finish the most essential part of my GUI. I still thank you. Ciao
Sebapabst