-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtranslator.py
96 lines (59 loc) · 2.35 KB
/
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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from tkinter import *
import tkinter as tk
from tkinter import ttk
from PIL import ImageTk, Image
from googletrans import Translator
from tkinter import messagebox
root = tk.Tk()
root.title('Translator India')
root.geometry('522x30')
root.maxsize(522,350)
root.minsize(522,350)
root.config(background="#000000")
root.iconphoto(False, tk.PhotoImage(file='icon/gt.png'))
def translate():
language_1 = t1.get("1.0","end-1c")
cl = choose_langauge.get()
if language_1 == '':
messagebox.showerror('Language Translator','empty')
else:
translator = Translator()
output = translator.translate(language_1, dest=cl)
t2.insert('end',output.text)
def clear():
t1.delete(1.0,'end')
t2.delete(1.0,'end')
a = tk.StringVar()
auto_detect = ttk.Combobox(root, width = 20, textvariable = a, state='readonly',font=('verdana',10,'bold'),)
auto_detect['values'] = (
'Auto Detect',
'English',
'Gujarati',
'Hindi',
'Malayalam',
'Marathi',
'Punjabi',
)
auto_detect.place(x=30,y=70)
auto_detect.current(0)
l = tk.StringVar()
choose_langauge = ttk.Combobox(root, width = 20, textvariable = l, state='readonly',font=('verdana',10,'bold'))
choose_langauge['values'] = (
'English',
'Gujarati',
'Hindi',
'Malayalam',
'Marathi',
'Punjabi',
)
choose_langauge.place(x=290,y=70)
choose_langauge.current(0)
t1 = Text(root,width=30,height=10,borderwidth=5,relief=RIDGE,)
t1.place(x=10,y=100)
t2 = Text(root,width=30,height=10,borderwidth=5,relief=RIDGE)
t2.place(x=260,y=100)
button = Button(root,text="Translate",relief=RIDGE,borderwidth=3,font=('verdana',10,'bold'),cursor="hand2",command=translate)
button.place(x=150,y=280)
clear = Button(root,text="Clear",relief=RIDGE,borderwidth=3,font=('verdana',10,'bold'),cursor="hand2",command=clear)
clear.place(x=280,y=280)
root.mainloop()