from tkinter import *
from tkinter import ttk
from googletrans import Translator, LANGUAGES
root = Tk()
root.geometry(‘1080×400′)
root.resizable(0, 0)
root.title(“Python Project | Language Translator”)
root.config(bg=’ghost white’)
# heading
Label(root, text=”Where Communication Is The Key”, font=”arial 20 bold”, bg=’white smoke’).pack()
Label(root, text=”Language Translator”, font=’arial 20 bold ‘, bg=’white smoke’, width=’20’).pack(side=’bottom’)
# INPUT AND OUTPUT TEXT WIDGET
Label(root, text=”Enter Text”, font=’arial 13 bold’, bg=’white smoke’).place(x=200, y=60)
Input_text = Text(root, font=’arial 10′, height=11, wrap=WORD, padx=5, pady=5, width=60)
Input_text.place(x=30, y=100)
Label(root, text=”Output”, font=’arial 13 bold’, bg=’white smoke’).place(x=780, y=60)
Output_text = Text(root, font=’arial 10′, height=11, wrap=WORD, padx=5, pady=5, width=60)
Output_text.place(x=600, y=100)
##################
Language = list(LANGUAGES.values())
src_lang = ttk.Combobox(root, values=Language, width=22)
src_lang.place(x=20, y=60)
src_lang.set(‘choose input language’)
dest_lang = ttk.Combobox(root, values=Language, width=22)
dest_lang.place(x=890, y=60)
dest_lang.set(‘choose output language’)
######## Define function #######
def Translate():
translator = Translator()
translated = translator.Translate(text=Input_text.get(1.0, END), src=src_lang.get(), dest=dest_lang.get())
Output_text.delete(1.0, END)
Output_text.insert(END, translated.text)
########## Translate Button ########
trans_btn = Button(root, text=’Translate’, font=’arial 12 bold’, pady=5, command=Translate, bg=’royal blue1′,
activebackground=’sky blue’)
trans_btn.place(x=490, y=180)
root.mainloop()
below is the error: Please solve this
Traceback (most recent call last):
File “C:\Users\tahir\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py”, line 1883, in __call__
return self.func(*args)
File “C:/Users/tahir/PycharmProjects/firstProject/main.py”, line 43, in Translate
Output_text.insert(END, translated.text)
AttributeError: ‘NoneType’ object has no attribute ‘text’