In a call to create a window (or anything) on your Canvas you need to specify its position - this is in part how a Canvas can be used as a geometry manager. e.g.:
my($bittag) = $canvar->create('bitmap',10,10, -bitmap=>'hourglass');
Specifies the x=10, y=10 screen pixel location (from the upper left). Other
possible units are:
tag unit example
pixels 25,50 # i.e. no unit tag at all
m milliimeters 10c,20c
c centimeters 1c,2c
p points (1/72") 35p,70p
There can be a great deal more to it than just units, however. Note the
following question posed and answered by Eric J. Bohm.
Eric J. Bohm <bohm@cs.buffalo.edu> wrote:
!I've got a row of entries packed side by side in a frame.
!These frames are packed on top of each other.
!So, when someone deletes a row, the lower ones bubble
!up automatically. This works just fine and dandy, and let me
!extend my thanks to our brave and energetic pTk team.
!
!The trick here is what widget do I put this in so that
!it will be scrollable when I have too many rows to
!fit on the screen?
[details and complaints]
Following up to my own message here.All right, after several false leads, I spent 3 hours fighting a canvas widget and pounding my head against the canvas.html doc, until I finally understood how to include my entries in a frame in a window in the canvas and get things to scroll nicely.
Turns out that the whole thing isn't all that hard to do once I understood how canvas widgets work.
Not sure if its of general interest, but here's the snippet, which was stolen from the items demo inside the widget_lib and then brutally hacked.
Perhaps a simpler demo would have been easier to use as a guide, but I got there eventually, so my thanks for the widget demo.
#----------------------------------------
my $c = $w_frame->Canvas();
$c->configure(
-height => '300',
-width => '600',
-relief => 'sunken',
-bd => 2,
);
my $w_frame_vscroll = $w_frame->Scrollbar(
-command => ['yview', $c]
);
my $w_frame_hscroll = $w_frame->Scrollbar(
-orient => 'horiz',
-command => ['xview', $c]
);
$c->configure(-xscrollcommand => ['set', $w_frame_hscroll]);
$c->configure(-yscrollcommand => ['set', $w_frame_vscroll]);
$w_frame_hscroll->pack(-side => 'bottom', -fill => 'x');
$w_frame_vscroll->pack(-side => 'right', -fill => 'y');
$c->pack(-expand => 'yes', -fill => 'both',-side=>'top');
my $entryframe=$c->Frame;
my $c_win= create $c 'window','0','0',
-window=>$entryframe,
-anchor=>'nw';
#----------------------------------------Where $c -> configure( -scrollregion => [$top, $left, $right, $bottom]) can be used to size things nicely once you find out how big it'll be.And the widgets you want scrolled should be slaves of $entryframe.
Vastly more robust than anything I had running in the BLT Table.
EJB
Previous | Return to table of contents | Next