Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I have a gui written in Perl Tk. I recently added a color bar to the gui to define the color represented on some graphs. I embedded a canvas in a canvas widget to go this and had the second canvas call a gif that represented the color bar.

It turned out great. The only thing that I can't figure out now is how to make the second canvas widget resizable so the user can grab the left hand side panel of the color bar and resize it to the right to see more of canvas1 with the graph.

Any help is greatly appreciated.
-Mark

Replies are listed 'Best First'.
Re: Perl Tk canvas in a canvas question
by herveus (Prior) on Sep 24, 2003 at 16:46 UTC
    Howdy!

    Tk::Adjuster is standard with Tk 800.025 (not sure how much earlier) and will let you do what you want.

    Tk::SplitFrame is another module that looks like it tries to do what you want done...

    yours,
    Michael

Re: Perl Tk canvas in a canvas question
by Plankton (Vicar) on Sep 24, 2003 at 16:47 UTC
    Maybe you could use a frame?
    #!/usr/bin/perl -w use strict; use Tk; use Tk::Canvas; my $width = 750; my $height = 750; my $x_max = $width; my $y_max = $height; my $x_min = 5; my $y_min = 5; my $top = MainWindow->new(); my $frame = $top->Frame(); my $can = $top->Canvas( -width => $width/2, -height=> $height ); sub clear{ $can->delete( 'all' ); } my $x = 0; my $y = 0; my $n = 0; my $start_x = 0; my $start_y = 0; $can->create ( 'line', $x_min, $y_min, $x_max, $y_max ); $can->create ( 'line', $x_min, $y_max, $x_max, $y_min ); $can->packAdjust( -side => 'left', -fill => 'both', -delay => 1 ); $frame->pack( -side => 'left', -fill => 'y', -expand => 'y', -anchor => 'w' ); my $can2 = $top->Canvas( -width => $width/2, -height=> $height ); $can2->packAdjust( -side => 'right', -fill => 'both', -delay => 1 ); $can2->create ( 'line', $x_min, $y_min, $x_max, $y_max ); $can2->create ( 'line', $x_min, $y_max, $x_max, $y_min ); MainLoop;

    Plankton: 1% Evil, 99% Hot Gas.
Re: Perl Tk canvas in a canvas question
by PodMaster (Abbot) on Sep 24, 2003 at 21:55 UTC
    Of course you can. Simply employ the rubberbanding technique from Tk Rubberband Demo.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.