Traducator in mai multe limbi
Aceasta aplicatie traduce in mai multe limbi si inapoi in engleza, raspunsul putand fi ciudat sau amuzantunknown
python
2 years ago
4.0 kB
7
Indexable
from tkinter import * from tkinter import messagebox from tkinter.ttk import Progressbar import arabic_reshaper import translators as ts import time import threading from PIL import ImageTk, Image def quitapp(): if messagebox.askokcancel("Quit", "Do you want to quit?"): exit() def update(): while True: window.update() def clear(): text.delete(1.0, END) window.update() def trans(): text.delete(1.0, END) # Clear the text area bar['value'] = 0 # Reset progress bar translated = entry.get() # Gets input from write area entry.config(state=DISABLED) # Disables entering text button.config(state=DISABLED) # Disables button exitbtn.config(state=DISABLED) clear.config(state=DISABLED) window.update() # Update GUI time.sleep(0.2) for i in range(1, 6): langs = ("en", "de", "zh", "ja", "ar", "en") source = langs[i - 1] to = langs[i] translating = ts.translate_text(translated, to_language=to, from_language=source, translator="google") translated = translating bar['value'] += 20 if to == "ar": text.insert(END, "----------------------\n") translated = arabic_reshaper.reshape(translated) text.insert(END, f'{translated} | from: {source} to: {to} [{i}/5]\n') else: text.insert(END, "----------------------\n") text.insert(END, f'{translated} | from: {source} to: {to} [{i}/5]\n') window.update() entry.config(state=NORMAL) # Enable entering text button.config(state=NORMAL) # Enable the button exitbtn.config(state=NORMAL) clear.config(state=NORMAL) window.update() # Update GUI text.insert(END, "----------------------\n") text.insert(END, f'ඞ Final Result: "{translated}" ඞ') # Write the end result in the text area window = Tk() window.geometry("600x800") window.title("Wolfy's Sus-Slator") window.configure(bg='black') label = Label(window, text="Wolfy's Sus-Slator", font=('Arial', 40, 'bold'), fg='lime', bg='black', relief=RAISED, bd=10, padx=20) label.place(x=40, y=30) entry = Entry(window, font=("Arial", 24)) entry.place(x=120, y=640) text = Text(window, font=("Arial", 16), height=16, width=40, bg="black", fg="lime", state=NORMAL) text.place(x=60, y=160) button = Button(window, text="Sus-Slate", command=trans, font=("Comic Sans", 24), fg="lime", bg="black", activebackground="lime", activeforeground="black", state=NORMAL, relief=RIDGE) button.place(x=220, y=700) exitbtn = Button(window, text="Exit", command=quitapp, font=("Comic Sans", 14), fg="lime", bg="black", activebackground="lime", activeforeground="black", state=NORMAL, relief=RIDGE, padx=20) exitbtn.place(x=75, y=710) clear = Button(window, text="Clear", command=clear, font=("Comic Sans", 14), fg="lime", bg="black", activebackground="lime", activeforeground="black", state=NORMAL, relief=RIDGE, padx=20) clear.place(x=435, y=710) bar = Progressbar(window, orient=HORIZONTAL, length=400) bar.place(x=100, y=600) # img = Image.open("kirbo.png") # kirby = ImageTk.PhotoImage(img) window.protocol("WM_DELETE_WINDOW", quitapp) window.mainloop()
Editor is loading...