forked from Aashishkumar123/Python-GUI-Project
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtranslator.py
More file actions
188 lines (156 loc) · 5.79 KB
/
translator.py
File metadata and controls
188 lines (156 loc) · 5.79 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
from tkinter import *
import tkinter as tk
from tkinter import ttk
from PIL import ImageTk, Image #pip install pillow
from googletrans import Translator #pip install googletrans==3.1.0a0
from tkinter import messagebox
root = tk.Tk()
root.title('Langauge Translator')
root.geometry('530x330')
root.maxsize(530,330)
root.minsize(530,330)
def translate():
language_1 = t1.get("1.0","end-1c")
cl = choose_langauge.get()
if language_1 == '':
messagebox.showerror('Language Translator','please fill the box')
else:
t2.delete(1.0,'end')
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')
img = ImageTk.PhotoImage(Image.open('translator.png'))
label = Label(image=img)
label.place(x=230,y=3)
a = tk.StringVar()
auto_detect = ttk.Combobox(root, width = 20, textvariable = a, state='readonly',font=('verdana',10,'bold'),)
auto_detect['values'] = (
'Auto Detect',
)
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'] = (
'Afrikaans',
'Albanian',
'Arabic',
'Armenian',
' Azerbaijani',
'Basque',
'Belarusian',
'Bengali',
'Bosnian',
'Bulgarian',
' Catalan',
'Cebuano',
'Chichewa',
'Chinese',
'Corsican',
'Croatian',
' Czech',
'Danish',
'Dutch',
'English',
'Esperanto',
'Estonian',
'Filipino',
'Finnish',
'French',
'Frisian',
'Galician',
'Georgian',
'German',
'Greek',
'Gujarati',
'Haitian Creole',
'Hausa',
'Hawaiian',
'Hebrew',
'Hindi',
'Hmong',
'Hungarian',
'Icelandic',
'Igbo',
'Indonesian',
'Irish',
'Italian',
'Japanese',
'Javanese',
'Kannada',
'Kazakh',
'Khmer',
'Kinyarwanda',
'Korean',
'Kurdish',
'Kyrgyz',
'Lao',
'Latin',
'Latvian',
'Lithuanian',
'Luxembourgish',
'Macedonian',
'Malagasy',
'Malay',
'Malayalam',
'Maltese',
'Maori',
'Marathi',
'Mongolian',
'Myanmar',
'Nepali',
'Norwegian'
'Odia',
'Pashto',
'Persian',
'Polish',
'Portuguese',
'Punjabi',
'Romanian',
'Russian',
'Samoan',
'Scots Gaelic',
'Serbian',
'Sesotho',
'Shona',
'Sindhi',
'Sinhala',
'Slovak',
'Slovenian',
'Somali',
'Spanish',
'Sundanese',
'Swahili',
'Swedish',
'Tajik',
'Tamil',
'Tatar',
'Telugu',
'Thai',
'Turkish',
'Turkmen',
'Ukrainian',
'Urdu',
'Uyghur',
'Uzbek',
'Vietnamese',
'Welsh',
'Xhosa'
'Yiddish',
'Yoruba',
'Zulu',
)
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()