Canvas is undoubtedly one of the most versatile widgets in tkinter. With Canvas, we can create shapes, texts, animate stuff, modeling 3D shapes, modeling simulations, and many more.
In order to add text inside a tkinter frame, we can use the create_text() method. We can define create_text() by adding values of font, text, and other options such as create_text(x,y,font, text, options….).
#Import the required library from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the geometry win.geometry("750x280") #Create a canvas object canvas= Canvas(win, width= 1000, height= 750, bg="SpringGreen2") #Add a text in Canvas canvas.create_text(300, 50, text="HELLO WORLD", fill="black", font=('Helvetica 15 bold')) canvas.pack() win.mainloop()
Running the above code will display a canvas with some text in it.