CairoMisr
CairoMisr

Reputation: 43

Is there a way to label an oval (canvas.create_oval) in Tkinter?

I have a canvas:

window = tk.Tk()
canvas = tk.Canvas(window,
              width=width,
              height=height,
              bg='black')

With an oval:

canvas.create_oval(x1, y1, x2, y2, fill='red')

Is it possible to label this oval as such:

enter image description here

*Keep in mind the oval in this image has a line coming out which is irrelevant to this question

Upvotes: 1

Views: 678

Answers (1)

ZisIzHell
ZisIzHell

Reputation: 139

One way to do it is to use create_text:

x = abs((x1-x2)/2)
y = abs((y1-y2)/2)
oval_label = canvas.create_text((x, y), text="Label text")

Upvotes: 3

Related Questions