I'm sure I'm missing something obvious here.

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$..$/

In reply to Undesired space between Tk Canvases by liverpole

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.