Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from googletrans import Translator
- root = Tk()
- root.title("Translator GUI")
- root.geometry("300x300")
- def reset():
- global root
- root.destroy()
- root = Tk()
- root.title("Translator GUI")
- root.geometry("300x300")
- lab = Label(root,text="Enter the text you would like to translate ?")
- lab.grid(row=0, column=2)
- tren = Entry(root, width=50)
- tren.grid(row=1, column=2)
- but = Button(root, text="Translate!", command= lambda : gtrans(tren.get()))
- but.grid(row=2, column=2, padx=5, pady=5)
- but2 = Button(root, text="Clear", command = lambda: reset())
- but2.grid(row=2, column=3, padx=5, pady=5)
- root.mainloop()
- def gtrans(text1):
- global root
- translator = Translator()
- result = translator.translate(text1)
- restext = result.text
- lab2 = Label(root, text="Translated Text:")
- lab2.grid(row=3, column=2)
- lab3 = Label(root, text=restext.strip())
- lab3.grid(row=4, column=2)
- lab = Label(root,text="Enter the text you would like to translate ?")
- lab.grid(row=0, column=2)
- tren = Entry(root, width=50)
- tren.grid(row=1, column=2)
- but = Button(root, text="Translate!", command= lambda : gtrans(tren.get()))
- but.grid(row=2, column=2, padx=5, pady=5)
- but2 = Button(root, text="Clear", command = lambda: reset())
- but2.grid(row=2, column=3, padx=5, pady=5)
- root.mainloop()
Add Comment
Please, Sign In to add comment