-
Notifications
You must be signed in to change notification settings - Fork 2
/
python-language-translator.py
56 lines (36 loc) · 1.81 KB
/
python-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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from tkinter import *
from tkinter import ttk
from googletrans import Translator , LANGUAGES
root = Tk()
root.geometry('1080x400')
root.resizable(0,0)
root.title("Project Gurukul--Language Translator")
root.config(bg = 'ghost white')
#heading
Label(root, text = "LANGUAGE TRANSLATOR", font = "arial 20 bold", bg='white smoke').pack()
Label(root,text ="Project Gurukul", 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()