File: ludevit_tk

package info (click to toggle)
ludevit 9.2-1.1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 172 kB
  • sloc: python: 984; makefile: 2
file content (60 lines) | stat: -rwxr-xr-x 1,690 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/python3
# -*- coding: utf-8 -*-

from tkinter import *
from tkinter.scrolledtext import ScrolledText

from ludevit_trans.translator import Translator
from ludevit_trans import tables_ludevit

translator = Translator(tables_ludevit.table_voc, tables_ludevit.table_ort, tables_ludevit.postprocess)
translate_text = translator.translate_text

class Application(Frame):
    def translate(self):
        self.TRANSLATED.delete("1.0", END)
        txt = self.TEXT.get("1.0", END)
        tr_txt = translate_text(txt)
        self.TRANSLATED.insert(END, tr_txt)
        self.TEXT.tag_add(SEL, "1.0", END)
        self.TEXT.focus_set()

    def createWidgets(self):

        top=self.winfo_toplevel()
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)

        self.TEXT = ScrolledText(self, width=32, height=24)
        self.TEXT.grid(row=0, column=0, sticky=N+S+W)

        self.TRANSLATED = ScrolledText(self, width=32, height=24)
        self.TRANSLATED.grid(row=0, column=1, sticky=N+S+E)

        self.QUIT = Button(self)
        self.QUIT["text"] = "skonči"
        self.QUIT["fg"]   = "red"
        self.QUIT["command"] =  self.quit

        self.QUIT.grid(row=1, column=1)


        self.trans = Button(self)
        self.trans["text"] = u"prelož",
        self.trans["command"] = self.translate

        self.trans.grid(row=1, column=0)
        self.TEXT.focus_set()

    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets()

root = Tk()
app = Application(master=root)
app.mainloop()
root.destroy()