Tkinter: Set 0, 0 Coords On The Bottom Of A Canvas
Solution 1:
The tkinter canvas does not support changing the coordinate system. You can scroll the canvas so that 0,0 appears in the bottom left corner, but that won't affect the coordinate system. Point (1,1) will always be to the right and below the point (0,0).
From the official tcl/tk documentation on the canvas (tkinter is just a wrapper around a tcl/tk interpreter):
COORDINATES
All coordinates related to canvases are stored as floating-point numbers. Coordinates and distances are specified in screen units, which are floating-point numbers optionally followed by one of several letters. If no letter is supplied then the distance is in pixels. If the letter is m then the distance is in millimeters on the screen; if it is c then the distance is in centimeters; i means inches, and p means printers points (1/72 inch). Larger y-coordinates refer to points lower on the screen; larger x-coordinates refer to points farther to the right. Coordinates can be specified either as an even number of parameters, or as a single list parameter containing an even number of x and y coordinate values.
TRANSFORMATIONS
Normally the origin of the canvas coordinate system is at the upper-left corner of the window containing the canvas. It is possible to adjust the origin of the canvas coordinate system relative to the origin of the window using the xview and yview widget commands; this is typically used for scrolling. Canvases do not support scaling or rotation of the canvas coordinate system relative to the window coordinate system.
Solution 2:
You could create a couple of variables that hold the size of the screen. then replace (0,0)
with (self.screenWidth-0, self.sceenHeight-0)
Post a Comment for "Tkinter: Set 0, 0 Coords On The Bottom Of A Canvas"