-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLanguage translator.py
47 lines (37 loc) · 1.62 KB
/
Language translator.py
1
#import required modulefrom tkinter import *from tkinter import ttkfrom googletrans import Translator ,LANGUAGES#create a display windowroot =Tk()root.geometry('1080x400')root.resizable(0,0)root.config(bg='ghost white')root.title("Project Anurag -- Language Tranaslator")Label(root, text = "Language Translator", font = 'arial 20 bold',bg='white smoke').pack()Label(root,text="Langusge Translator", font='arial 13 bold',bg='white smoke').pack(side=BOTTOM)#create a input output text widgetLabel(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)#define combobocx to select a languagelanguage=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 functionsdef 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)#create a translate buttontrans_btn=Button(root,text='Translate',font='arial 12 bold',pady=5,command=Translate,bg='royal blue',activebackground='sky blue')trans_btn.place(x=490,y=180)root.mainloop()