Tkinter Canvas Output Text
create_text() It is used in the following way.
create_text (x,y,text=string, options)
The default (x,y) is the center coordinate of the text string output. The following are the common uses of options.
(1) anchor
: the default is anchor=CENTER.
(2) fill
: the color of the text.
(3) font
: the use of glyphs.
(4) justify
: When outputting multiple lines, the default is to the left LEFT.
(5) stipple
: text for drawing bitmap lines, the default is "" for solid lines.
(6) text
: the output text.
(7) width
: width of polygon lines.
Example#1
Output text application.
from tkinter import *
tk = Tk()
tk.title("apidemos.com")
canvas = Canvas(tk, width=640, height=480)
canvas.pack()
myStr = "welcome to apidemos.com"
canvas.create_text(200, 50, text=myStr)
canvas.create_text(200, 80, text=myStr, fill='blue')
canvas.create_text(300, 120, text=myStr, fill='blue',
font=('Old English Text MT',20))
tk.mainloop()
Output: