Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

scrollbar not working xaxis

by reaper9187 (Scribe)
on Dec 22, 2012 at 14:31 UTC ( #1010017=perlquestion: print w/ replies, xml ) Need Help??
reaper9187 has asked for the wisdom of the Perl Monks concerning the following question:

Hi every one ...
I'm using perl Tk and i'm having problems with setting the scrollbars.... I need to use two scrollbars,... The following code only enables the vertical scroller while the horizontal scrollbar is not created .. How can i do that ??
#!/usr/local/bin/perl use Tk; my $mw = new MainWindow; # Main Window my $frm_name = $mw -> Frame(); my $lab = $frm_name -> Label(-text=>"Name:"); my $ent = $frm_name -> Entry(); my $but = $mw -> Button(-text=>"Push Me", -command =>\&push_button); my $textarea = $mw -> Frame(); #Creating Another Frame my $txt = $textarea -> Text(-width=>40, -height=>10); my $srl_y = $textarea -> Scrollbar(-orient=>'v',-command=>[yview => $t +xt]); my $srl_x = $textarea -> Scrollbar(-orient=>'h',-command=>[xview => $t +xt]); $txt -> configure(-yscrollcommand=>['set', $srl_y], -xscrollcommand=>['set',$srl_x]); $lab -> grid(-row=>1,-column=>1); $ent -> grid(-row=>1,-column=>2); $frm_name -> grid(-row=>1,-column=>1,-columnspan=>2); $but -> grid(-row=>4,-column=>1,-columnspan=>2); $txt -> grid(-row=>1,-column=>1); $srl_y -> grid(-row=>1,-column=>2,-sticky=>"ns"); $srl_x -> grid(-row=>2,-column=>1,-sticky=>"ew"); $textarea -> grid(-row=>5,-column=>1,-columnspan=>2); MainLoop; #This function will be executed when the button is pushed sub push_button { my $name = $ent -> get(); $txt -> insert('end',"Hello, $name."); }

Comment on scrollbar not working xaxis
Download Code
Replies are listed 'Best First'.
Re: scrollbar not working xaxis
by thundergnat (Deacon) on Dec 22, 2012 at 16:36 UTC

    The scrollbar IS enabled. It just doesn't seem like it because of the default Text wrap option. Try a different wrap option. For example, change line 13 to:

    my $txt = $textarea -> Text(-width=>40, -height=>10, -wrap => 'none');
Re: scrollbar not working xaxis
by stefbv (Deacon) on Dec 22, 2012 at 16:46 UTC

    thundergnat was faster... :-)

    Easier to use Tk::Scrolled for the Text widget:

    use strict; use warnings; use Tk; my $mw = MainWindow->new(); my $text = $mw->Scrolled( 'Text', -width => 40, -height => 10, -wrap => 'none', -scrollbars => 'se', -background => 'white', )->grid( -row => 0, -column => 0, ); MainLoop;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1010017]
Approved by ww
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2015-11-27 03:16 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (715 votes), past polls