

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How to 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.
- Related Questions & Answers
- Creating a LabelFrame inside a Tkinter Canvas
- Tkinter - How to put an outline on a canvas text
- Create a text inside circles in HTML5 Canvas
- How to add text inside a plot in Matplotlib?
- How to put an outline on a canvas text on Tkinter?
- Add a caption text inside a thumbnail class
- Add advanced features to a tkinter Text widget
- How to set the font size of a Tkinter Canvas text item?
- How to clear Tkinter Canvas?
- How to make a Tkinter canvas rectangle transparent?
- How to move a Tkinter canvas with Mouse?
- How to reconfigure Tkinter canvas items?
- How to create a Button on a Tkinter Canvas?
- How to draw a line on a Tkinter canvas?
- How to highlight text in a tkinter Text widget?
Advertisements