I need the text to be entered using a widget Entry and launched on the enter button.
entry = tk.Text(root, width=30, height=1)
entry.bind("<Return>")
entry.pack()
entry.focus()
Here is an example, but I don’t know how to insert it into the program.
import tkinter as tk
from tkinter import *
root = tk.Tk()`
c = tk.Canvas(root)
c.pack(expand=1, fill=tk.BOTH)
words = 'London is capital of Great Britain.'
words = words.split()
def new_word(i):
if i == len(words):
i = 0
word = words[i]
middle = (len(word)+1)//2
c.itemconfigure(t1, text=word[:middle-1]+' ')
c.itemconfigure(t2, text=word[middle-1:middle])
c.itemconfigure(t3, text=word[middle:])
root.after(100, lambda: new_word(i+1))
t1 = c.create_text(200,100,text='', anchor='e', font=("Courier", 25))
t2 = c.create_text(200,100,text='', anchor='e', font=("Courier", 25), fill='red')
t3 = c.create_text(200,100,text='', anchor='w', font=("Courier", 25))
new_word(0)
root.geometry('400x200+200+200')
root.mainloop()
Thanks in advance.