-
Notifications
You must be signed in to change notification settings - Fork 1
/
tranlator.py
82 lines (43 loc) · 1.82 KB
/
tranlator.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from tkinter import *
from tkinter import ttk
#from googletrans import Translator, LANGUAGES
from googletrans import Translator, LANGUAGES
def changes(text='type', src='English', dest='Hindi'):
text1=text
src1=src
dest1=dest
trans= Translator()
trans1 = trans.translate(text, src, dest)
return trans1.text
def data():
s= comb_sor.get()
d=comb_dest.get()
masg= Sor_txt.get(1.0, END)
textget = changes(text=masg, src=s, dest=d)
dest_txt.delete(1.0, END)
dest_txt.insert(END, textget)
root=Tk()
root.title("Translator")
root.geometry("500x700")
root.config(bg='Red')
lab_txt=Label(root, text='Translator', font=("Times New Roman", 40, 'bold'))
lab_txt.place(x=100, y=40, height=50, width=300)
frame=Frame(root).pack(side=BOTTOM)
lab_txt=Label(root, text='Source text', font=("Times New Roman", 20, 'bold'), fg='Black', bg="Red")
lab_txt.place(x=100, y=100, height=20, width=300)
Sor_txt=Text(frame,font=("Times New Roman", 20, 'bold'), wrap=WORD )
Sor_txt.place(x=10, y=130, height=150, width=480)
list_text= list(LANGUAGES.values())
comb_sor= ttk.Combobox(frame, value=list_text)
comb_sor.place(x=10, y=300, height=40, width=100)
comb_sor.set("English")
button_change=Button(frame, text='Translate', relief=RAISED, command=data)
button_change.place(x=170, y=300, height=40, width=150)
comb_dest= ttk.Combobox(frame, value=list_text)
comb_dest.place(x=330, y=300, height=40, width=150)
comb_dest.set("English")
lab_txt=Label(root, text='Dest text', font=("Times New Roman", 20, 'bold'), fg='Black', bg="Red")
lab_txt.place(x=100, y=360, height=20, width=300)
dest_txt=Text(frame,font=("Times New Roman", 20, 'bold'), wrap=WORD )
dest_txt.place(x=10, y=400, height=150, width=480)
root.mainloop()