Here we are providing a basic tutorial in Tkinter on how to create text and arcs in a Tkinter.

Sample code for arcs

The following Tkinter code will demonstrate the arcs:

from tkinter import *
import random

root = Tk()
canvas = Canvas(root, width=300, height=300)
canvas.pack()

canvas.create_arc(10,10,200,40,extent = 45, style = ARC)
canvas.create_arc(10,40,200,80,extent = 90, style = ARC)
canvas.create_arc(10,80,200,160,extent = 180, style = ARC)
canvas.create_arc(10,160,200,240,extent = 359, style = ARC)


root.mainloop()


In above code, we created four arcs using the create_arc method. Parameter that must be noted is extent that is used to define the angle for the arc, since tkinter finds 360 degrees to be equivalent to 0 degree, we therefore made the last arc with an angle of 359 degrees.

Output

output


Sample code for text

The following Tkinter code will demonstrate the text:

from tkinter import *
import random

root = Tk()
canvas = Canvas(root, width=300, height=300)
canvas.pack()

canvas.create_text(150,150,text = "Awesome",font = ("Times",30))

root.mainloop()


In above code, text is created in the canvas using create_text method. Parameters are co-ordinates for the text to display, text itself, font-size and font-family. Rest code is self-explanatory.

Output

output