For Programmers: Free Programming Magazines  


Home > Archive > Tcl > June 2007 > The size of the canvas









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author The size of the canvas
iu2

2007-06-24, 8:11 am

Hi all,
Can you please help me with this:

I creaeted a canvas and packed it, then drew three rectangles:

wm state . zoomed
canvas .can -width 300 -bg white
pack .can -expand 1 -fill y
..can create rectangle 0 100 300 200 -fill blue
..can create rectangle 0 0 100 [.can cget -height] -fill green
update
..can create rectangle 100 0 200 [winfo reqheight .can] -fill purple

1. The first rect (blue) doesn't reach the end of the canvas (2-3
pixels left white). Why?
2. The second rect (green) doesn't stretch untill the bottom. I fact
it is less long than half of the height of the canvas. It seems that
the packer and the canvas think differenly about their sizes. How can
I fix this?
I tried to fix it in the purple rect, using reqheight but that didn't
help either.

Thanks

Arjen Markus

2007-06-24, 8:11 am

On 24 jun, 07:05, iu2 <isra...@elbit.co.il> wrote:
> Hi all,
> Can you please help me with this:
>
> I creaeted a canvas and packed it, then drew three rectangles:
>
> wm state . zoomed
> canvas .can -width 300 -bg white
> pack .can -expand 1 -fill y
> .can create rectangle 0 100 300 200 -fill blue
> .can create rectangle 0 0 100 [.can cget -height] -fill green
> update
> .can create rectangle 100 0 200 [winfo reqheight .can] -fill purple
>
> 1. The first rect (blue) doesn't reach the end of the canvas (2-3
> pixels left white). Why?
> 2. The second rect (green) doesn't stretch untill the bottom. I fact
> it is less long than half of the height of the canvas. It seems that
> the packer and the canvas think differenly about their sizes. How can
> I fix this?
> I tried to fix it in the purple rect, using reqheight but that didn't
> help either.
>
> Thanks


Problem 1 is due to the border that a canvas maintains. Set
borderwidth
to 0 to turn it off.

Problems 2 and 3 are odd indeed. The canvas keeps reporting 264 and
268
for height and reqheight. But you can draw higher objects.

If you use [winfo height .can] you get the right values.

Regards,

Arjen

iu2

2007-06-25, 8:10 am

On Jun 24, 11:30 am, Arjen Markus <arjen.mar...@wldelft.nl> wrote:
> On 24 jun, 07:05, iu2 <isra...@elbit.co.il> wrote:
>
>
>
>
>
>
>
>
>
>
> Problem 1 is due to the border that a canvas maintains. Set
> borderwidth
> to 0 to turn it off.
>
> Problems 2 and 3 are odd indeed. The canvas keeps reporting 264 and
> 268
> for height and reqheight. But you can draw higher objects.
>
> If you use [winfo height .can] you get the right values.
>
> Regards,
>
> Arjen- Hide quoted text -
>
> - Show quoted text -


Thanks, that worked.
One comment though, I should have also used 301 instead of 300 for the
far x coord since Tk doesn't include the last x,y coords themselves in
the shape.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com