-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject(translator).py
More file actions
59 lines (42 loc) · 1.75 KB
/
project(translator).py
File metadata and controls
59 lines (42 loc) · 1.75 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
from tkinter import *
from tkinter import ttk
from googletrans import Translator, LANGUAGES
def change(text = "type", src = "English", dest = "Nepali"):
text1 = text
src1 = src
dest1 = dest
trans = Translator()
trans1 = trans.translate(text1, src = src1, dest = dest1)
return trans1.text
def data():
s = comb_sor.get()
d = comb_dest.get()
masg = Sor_txt.get(1.0,END)
textget = change(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",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",20,"bold"),fg = "Black", bg = "Red")
lab_txt.place(x=100, y=100, height=20, width=300)
Sor_txt = Text(frame, font =("Times New",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=150)
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 = "Source Text", font =("Times New",20,"bold"),fg = "Black", bg = "Red")
lab_txt.place(x=100, y=100, height=20, width=300)
dest_txt = Text(frame, font =("Times New",20,"bold"),wrap = WORD)
dest_txt.place(x=10, y=400, height=150, width=480)
root.mainloop()