简体   繁体   中英

Tkinter: Set 0, 0 coords on the bottom of a canvas

When I usually create a canvas, the (0, 0) coord is place on the top left corner of it. Now I want to set it on the bottom left corner. I think I have to set the "scrollbarregion" but I can't understand how to do it. Can someone explain?

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM