Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Tk TableMatrix/Pane geometry problem

by Anonymous Monk
on Sep 13, 2013 at 17:05 UTC ( #1053969=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks

I'm working on a Tk GUI and I have a rather small problem, but I can't figure pout what I'm doing wrong. I'm using TK::TableMatrix and I can't let the table fill the whole pane if the user enlarge the main window. Here's a simplified working code

#!/usr/bin/perl -w use warnings; use Tk; use Tk::Pane; use Tk::TableMatrix; my $mw_top = MainWindow->new(); $mw_top->geometry( "826x900" ); $mw_top->resizable(1, 1 ); our $mw = $mw_top->Scrolled(Pane, Name => 'fred', -scrollbars => 's', -sticky => 'we', -gridded => 'y', -background => 'blue' ); $mw->Frame; $mw->pack(-expand => 1, -fill => 'both'); GUI(); Tk::MainLoop; sub GUI { my $frame_commons_first_level = $mw->Frame (-background => 'white')->p +ack(-side => 'top', -expand => '0'); my $frame_entry_info = $mw->Frame (-background => 'white')->pack(-side + => 'top', -expand => '0'); my $frame_table = $mw->Frame( -background => 'white',-relief => 'ridge +')->pack(-side => 'top', -expand => '1', -fill => 'both'); my $rows=100; my $cols=10; foreach my $row (0..($rows-1)){ $arrayVar->{"$row,0"} = "$row"; } foreach my $col (0..($cols-1)){ $arrayVar->{"0,$col"} = "$col"; } sub colSub{ my $col = shift; return "OddCol" if( $col > 0 && $col%2) ; } our $t = $frame_table->Scrolled('TableMatrix', -rows => $rows, -cols => $cols, -height => 60, -titlerows => 1, -titlecols => 0, -variable => $arrayVar, -coltagcommand => \&colSub, -browsecommand => \&brscmd, -colstretchmode => 'last', -wrap=>1, -multiline=>1, -relief => 'ridge', -rowstretchmode => 'last', -selectmode => 'extended', -selecttype=>'row', -selecttitles => 0, -drawmode => 'slow', -scrollbars=>'e', -ipadx=>3, -pady=>3, -padx=>1, )->pack(-expand => '1', -fill => 'both'); }

Where is the fault?

Comment on Tk TableMatrix/Pane geometry problem
Download Code
Replies are listed 'Best First'.
Re: Tk TableMatrix/Pane geometry problem
by kcott (Abbot) on Sep 14, 2013 at 00:31 UTC

    To fix your current problem, change

    -sticky => 'we',

    to

    -sticky => 'nsew',

    See Tk::Pane for details.

    You also have quite a lot of other issues. Here's half a dozen that seemed immediately obvious:

    • my $mw = MainWindow->new(); is a fairly standard convention. By using $mw for a different window, your code becomes confusing.
    • You have "our $mw = $mw_top->Scrolled(Pane, ...". Beyond the $mw issue (in the last point), why are you using our instead of my?
    • -gridded => 'y' is meaningless. See Tk::Pane for the reason.
    • $mw->Frame; is pointless: other than using some memory and CPU, it does nothing.
    • $frame_commons_first_level and $frame_entry_info have no content.
    • our $t: again, why are you using our instead of my?

    -- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1053969]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2015-07-30 00:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls