[Tkinter-discuss] (0,0) off the visible area of a Canvas
Fredrik Lundh
fredrik at pythonware.com
Mon Sep 12 14:40:37 CEST 2005
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>
More information about the Tkinter-discuss
mailing list