Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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."); }

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
[mark4]: Do you h=know how I can get pp.exe? Is there a module I can install that includes this?
[marto]: I always found Strawberry Perl on windows to be a much better environment, made life much easier
[marto]: pp. install it like you would any other module
[marto]: it probably exists in one of the PPM repositories
[marto]: failing that see the README
[mark4]: I installed "PAR" from the ppm install window. pp.exe. did not show up.
[marto]: it should just be a script, pp, or on windows pp.bat, post install you should just be able to call pp -x packed.exe as the PPM package should put everything required into the appropriate path
[marto]: ah, some time ago pp became it's own package, try searching your repo for PAR::Packer

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (14)
As of 2018-01-19 14:15 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (218 votes). Check out past polls.