有没有办法在 Tkinter 中标记椭圆形 (canvas.create_oval)?
Is there a way to label an oval (canvas.create_oval) in Tkinter?
我有一个 canvas
:
window = tk.Tk()
canvas = tk.Canvas(window,
width=width,
height=height,
bg='black')
oval
:
canvas.create_oval(x1, y1, x2, y2, fill='red')
是否可以这样标记这个椭圆:
*请记住这张图片中的椭圆有一条线出来,这与这个问题无关
一种方法是使用 create_text
:
x = abs((x1-x2)/2)
y = abs((y1-y2)/2)
oval_label = canvas.create_text((x, y), text="Label text")
我有一个 canvas
:
window = tk.Tk()
canvas = tk.Canvas(window,
width=width,
height=height,
bg='black')
oval
:
canvas.create_oval(x1, y1, x2, y2, fill='red')
是否可以这样标记这个椭圆:
*请记住这张图片中的椭圆有一条线出来,这与这个问题无关
一种方法是使用 create_text
:
x = abs((x1-x2)/2)
y = abs((y1-y2)/2)
oval_label = canvas.create_text((x, y), text="Label text")