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

久未见 提交于 2021-01-27 12:33:27

问题


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?


回答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.




回答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)



来源:https://stackoverflow.com/questions/41652978/tkinter-set-0-0-coords-on-the-bottom-of-a-canvas

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!