liverpole has asked for the wisdom of the Perl Monks concerning the following question:
Within my Perl/Tk application, I'd like to have a 256x256 white Canvas in the center of 4 other Canvas objects (of different colors here, while debugging).
I've tried every option I can think of, searched for a possible solution, and perused the most recent volume of "Mastering Perl/Tk" -- all to no avail.
Here is a stripped down version of my original program which still shows the problem. When you run it, you get a white Canvas in the middle of 4 Canvas "strips" of other colors. I'd like the Canvas objects to all be flush with one another, but there's a little space between each of them.
I know this has to be something simple and easy, but I'm just not seeing it. It's not the enclosing Frame (at least I don't think it is), because the Frame has a blue background, and there isn't any blue showing through anywhere.
Can someone point me to a solution? Thanks!
#!/usr/bin/perl -w # Strict use strict; use warnings; # Libraries use Tk; # Main program create_gui(); # Subroutines sub create_gui { my $mw = new MainWindow(-title => 'Type "Escape" to exit...'); $mw->bind('<Escape>' => sub { $mw->destroy() }); my $frame = $mw->Frame(-background => 'blue'); $frame->pack(-expand => 0, -fill => 'both'); # Note: 288 = 256 + 16 + 16 canvas($frame, 'hotpink', 'left', 16, 256 + 16 + 16); canvas($frame, 'gold', 'right', 16, 256 + 16 + 16); canvas($frame, 'maroon', 'top', 256, 16); canvas($frame, 'white', 'top', 256, 256); canvas($frame, 'purple', 'bottom', 256, 16); MainLoop; } sub canvas { my ($w, $background, $side, $width, $height) = @_; my $canvas = $w->Canvas(-background => $background); $canvas->configure(-width => $width); $canvas->configure(-height => $height); $canvas->pack(-expand => 1, -fill => 'both', -side => $side); return $canvas; } # # Key: H = Hotpink, M = Maroon, P = Purple, G = Gold, . = White # # The GUI I'm actually getting: The GUI I'd *LIKE* to get: # # +------------------------------+ +------------------------------+ # |Tk Type "Escape" to exit..." | |Tk Type "Escape" to exit..." | # +------------------------------+ +------------------------------+ # |H MMMMMMMMMMMMMMMMMMMMMMMM G| |HMMMMMMMMMMMMMMMMMMMMMMMMMMMMG| # |H G| |H............................G| # |H ........................ G| |H............................G| # |H ........................ G| |H............................G| # |H ........................ G| |H............................G| # |H ........................ G| |H............................G| # |H ........................ G| |H............................G| # |H ........................ G| |H............................G| # |H ........................ G| |H............................G| # |H ........................ G| |H............................G| # |H G| |H............................G| # |H PPPPPPPPPPPPPPPPPPPPPPPP G| |HPPPPPPPPPPPPPPPPPPPPPPPPPPPPG| # +------------------------------+ +------------------------------+ #
Update: After Super-Searching some more, I came across this node, by the venerable zentara. He used a Canvas option I hadn't tried: -highlightthickness => 0.
Although I'm still not exactly sure what highlightthickness is used for, it does the trick; inserting the following line completely addresses my problem:
$canvas->configure(-highlightthickness => 0);
Thanks, zentara -- you help me even when you're not logged in!
s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Undesired space between Tk Canvases
by shmem (Chancellor) on Apr 25, 2007 at 04:44 UTC | |
by liverpole (Monsignor) on Apr 25, 2007 at 13:46 UTC |