File: ludevit_tk

package info (click to toggle)
ludevit 6.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 172 kB
  • ctags: 119
  • sloc: python: 947; makefile: 47
file content (55 lines) | stat: -rwxr-xr-x 1,500 bytes parent folder | download
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
#!/usr/bin/python
# -*- coding: utf-8 -*-

from Tkinter import *
from ScrolledText import ScrolledText

from ludevit_trans.translator import 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"] = u"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()