-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLanguage Translator.py
35 lines (34 loc) · 1.48 KB
/
Language Translator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from tkinter import *
from translate import Translator
Screen = Tk()
Screen.title("Language Translator with Ishita")
Screen.geometry("600x400")
Screen.configure(bg='gray')
InputLanguageChoice = StringVar()
TranslateLanguageChoice = StringVar()
LanguageChoices = {'Hindi','English','French','German','Spanish','Punjabi'}
InputLanguageChoice.set('English')
TranslateLanguageChoice.set('Hindi')
def Translate():
translator = Translator(from_lang= InputLanguageChoice.get(),to_lang=TranslateLanguageChoice.get())
Translation = translator.translate(TextVar.get())
OutputVar.set(Translation)
#choice for input language
InputLanguageChoiceMenu = OptionMenu(Screen,InputLanguageChoice,*LanguageChoices)
Label(Screen,text="Choose a Language").grid(row=0,column=1)
InputLanguageChoiceMenu.grid(row=1,column=1)
#choice in which the language is to be translated
NewLanguageChoiceMenu = OptionMenu(Screen,TranslateLanguageChoice,*LanguageChoices)
Label(Screen,text="Translated Language").grid(row=0,column=2)
NewLanguageChoiceMenu.grid(row=1,column=2)
Label(Screen,text="Enter Text").grid(row=2,column =0)
TextVar = StringVar()
TextBox = Entry(Screen,textvariable=TextVar).grid(row=2,column = 1)
Label(Screen,text="Output Text").grid(row=2,column =2)
OutputVar = StringVar()
TextBox = Entry(Screen,textvariable=OutputVar).grid(row=2,column = 3)
B = Button(Screen,text="Translate",command=Translate, relief = GROOVE).grid(row=3,column=1,columnspan = 3)
mainloop()
print()
print("TASK COMPLETED THANK YOU")
print()