[Tkinter-discuss] Missing pixels whith create_line

Michael Lange klappnase at web.de
Mon Jan 31 17:30:42 CET 2011


Hi Georges,

Thus spoketh Georges Arsouze <georges.arsouze at gmail.com> 
unto us on Mon, 31 Jan 2011 13:22:46 +0100:

> With python3.1 I write this program
> When I click buton1 there are missing pixels at the end of horizontal
> and vertical lines
> why

The Canvas widget takes the width of the border and the "highlight" (the
additional border that is used to indicate that the widget has keyboard
focus) into account when it calculates its coordinates. So the solution
to your problem should be to either set borderwidth and
highlightthickness to 0 when you create the widget or to include the
border(s) into your calculations.
My recommendation is to set them both to 0 (and in case you need a
decorative border and/or the focus highlight, to pack the Canvas into a
separate Frame which has bd=2, highlighthickness=1 or so), especially if
you have a lot of items and their coords will be recalculated while the
program is running, this might save you quite some headaches. In order to
"emulate" focus highlight it is easy to bind a callback to <FocusIn> and
<FocusOut> events on the canvas, which will toggle the surrounding
frame's highlightcolor option.

I hope this helps

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

First study the enemy.  Seek weakness.
		-- Romulan Commander, "Balance of Terror", stardate 1709.2


More information about the Tkinter-discuss mailing list