Hi,
I'm trying to implement something similar to Excell's "Freeze Panes" functionality.
I would like to have a table when only the cells scroll and the headings stay on top.
See the attached code for an example. I would like the '0' and '1' headings to stay on top.
A possible solution is to put two frames one on top of the other, when only the lower is scrollable. This works but you loose the strength of the "grid" geometry manager, and you need to take care of the sizes so the columns align all right.
Thanks!
use strict; use Tk; use Tk::Pane; my $sc; my $x; my $i; my $j; my $box; my $mw = MainWindow->new; my $frame = $mw->Scrolled("Frame", -scrollbars => 'osoe', -sticky => 'nsew', -bg => 'black', -width => 900, -height => 500 )->pack(qw/-expand 1 -fill both/); foreach $i (0 .. 1) { $frame->Label( -text => $i, -relief => 'groove', -font => "{Arial} 15 bold", -borderwidth => 2, )->grid( -row => 0, -sticky=>"nsew", -column => $i, ); foreach $j (1 .. 4) { $sc = $frame->Canvas( -width => 400, -height => 125, -background => randColor() )->grid( -row => $j, -sticky => "nsew", -column => $i, ); $x = randNumber(); $box = $sc->createRectangle($x, 50, $x+20, 90, -fill => randColor(), -outline => 'black', -width => 2, -tags => 'rect', ); $sc->createLine( 10,100, 790,100, -arrow => 'last'); for($x=50;$x<800;$x+=50){ $sc->createLine( $x,95, $x,105 ); } } } MainLoop; sub randColor { my @colors = qw(red yellow blue orange green purple cyan pink); return $colors[rand($#colors + 1)]; } sub randNumber { my ($max, $min) = (350, 50); my $size = int(rand($max)); $size += $min if $size < $min; return $size; }

In reply to Tk:: How to do a pane which scrolls partially by tcarmeli

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.