
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Add Text Inside a Tkinter Canvas
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?.).
Example
#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()
Output
Running the above code will display a canvas with some text in it.
Advertisements