简体   繁体   English

在 Tkinter 画布中放置形状

[英]Placing Shapes In Tkinter Canvas

I've created a shape in the canvas using tkinter: ball=canvas.create_oval(0, 0, 20, 20, fill="saddle brown") However, I was wondering how to specify exactly where on the canvas the shape would be drawn.我已经使用 tkinter 在画布中创建了一个形状: ball=canvas.create_oval(0, 0, 20, 20, fill="saddle brown")但是,我想知道如何在画布上准确指定形状的位置绘制。 I have tried changing the coordinates 0, 0, 20, 20 but that just changes the size of the shape.我曾尝试更改坐标 0、0、20、20,但这只会改变形状的大小。 Any help would be appreciated!任何帮助将不胜感激!

The following coordinates will have the ball at a different location:以下坐标将使球位于不同的位置:

ball=canvas.create_oval(40, 40, 60, 60, fill="saddle brown")

The coordinates x0 , y0 , x1 , y1 of create_oval(x0, y0, x1, y1) are the top left and bottom right of the bounding box of the oval you are creating. create_oval(x0, y0, x1, y1)的坐标x0y0x1y1是您正在创建的椭圆的边界框的左上角和右下角。

在此处输入图片说明

If you have a look here , you will find additional useful information.如果您查看此处,您会发现更多有用的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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