(0,0) off the visible area of a Canvas

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

(0,0) off the visible area of a Canvas

Bill Barksdale
I am sure this must be a common question but I couldn't find anything
about it.

When I run the following on my system, the first line appears cut off
and the second line doesn't appear at all.  I believe this is because
(0,0) is not part of the visible area of a canvas, and that it starts
instead at (3,3) or thereabouts.  How can I fix this?

import Tkinter as TK
root = TK.Tk()
canv = TK.Canvas(root,width=100,height=100,bg='red')
canv.pack()
canv.create_line(0,100,100,0)
canv.create_line(0,0,0,100)

Thanks,
--Bill Barksdale

_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|

Re: (0,0) off the visible area of a Canvas

Michael Lange
On Sun, 11 Sep 2005 22:08:04 -0400
Bill Barksdale <[hidden email]> wrote:

> I am sure this must be a common question but I couldn't find anything
> about it.
>
> When I run the following on my system, the first line appears cut off
> and the second line doesn't appear at all.  I believe this is because
> (0,0) is not part of the visible area of a canvas, and that it starts
> instead at (3,3) or thereabouts.  How can I fix this?
>
> import Tkinter as TK
> root = TK.Tk()
> canv = TK.Canvas(root,width=100,height=100,bg='red')
> canv.pack()
> canv.create_line(0,100,100,0)
> canv.create_line(0,0,0,100)
>
Hi Bill,

I think the line is being hidden under the Canvases border, so you can try:

    canv.configure(bd=0, highlightthickness=0)

and if you need a decorative border pack the canvas into another Frame.

I hope this helps

Michael
_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|

Re: (0,0) off the visible area of a Canvas

Fredrik Lundh
In reply to this post by Bill Barksdale
Bill Barksdale wrote:

> I am sure this must be a common question but I couldn't find anything
> about it.
>
> When I run the following on my system, the first line appears cut off
> and the second line doesn't appear at all.  I believe this is because
> (0,0) is not part of the visible area of a canvas, and that it starts
> instead at (3,3) or thereabouts.  How can I fix this?
>
> import Tkinter as TK
> root = TK.Tk()
> canv = TK.Canvas(root,width=100,height=100,bg='red')
> canv.pack()
> canv.create_line(0,100,100,0)
> canv.create_line(0,0,0,100)

stock answer:

    by default, the coordinate system is aligned with the widget's upper
    left corner, which means that things you draw will be covered by the
    inner border.

    to fix this, you can either set the border width to zero, add scrollbars
    to the widget (this fixes the coordinate system), or explicitly reset the
    coordinate system:

    w.xview_moveto(0)
    w.yview_moveto(0)

</F>



_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss