File: testUI.py

package info (click to toggle)
csound 1%3A6.18.1%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 63,220 kB
  • sloc: ansic: 192,643; cpp: 14,149; javascript: 9,654; objc: 9,181; python: 3,376; java: 3,337; sh: 1,840; yacc: 1,255; xml: 985; perl: 635; lisp: 411; tcl: 341; lex: 217; makefile: 128
file content (65 lines) | stat: -rw-r--r-- 1,826 bytes parent folder | download | duplicates (3)
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
61
62
63
64
65
try:
    # Python 3
    from tkinter import *
except:
    try:
    # Python 2
     from Tkinter import *
    except:
     pass

class TestApplication(Frame):
    def selectTest(self):
        selected = self.listBox.curselection()[0]
        self.textBox.insert(0, selected[5])

    def createWidgets(self):

        self.scrollbar = Scrollbar(self)
        self.scrollbar.grid(row=0, column=1, sticky="ns")

        self.listBox = Listbox(self, yscrollcommand=self.scrollbar.set)
        self.listBox.grid(row=0, column=0, sticky="ew")      

        self.scrollbar2 = Scrollbar(self)
        self.scrollbar2.grid(row=1, column=1, sticky="ns")
        
        self.textBox = Text(self, yscrollcommand=self.scrollbar2.set)
        self.textBox.grid(row=1, column=0, sticky="nsew")

        self.scrollbar.config(command=self.listBox.yview)
        self.scrollbar2.config(command=self.textBox.yview)
        
        self.current = None
        self.poll() # start polling the list
    
    def poll(self):
        now = self.listBox.curselection()
        if now != self.current:
            self.list_has_changed(now)
            self.current = now
        self.after(250, self.poll)

    def list_has_changed(self, selection):
        if len(selection) > 0:
            self.textBox.delete(1.0, END)
            self.textBox.insert(END, self.results[int(selection[0])][3])

    def setResults(self, results):
        self.results = results

        label = "%s (%s)"
        
        for i in results:            
            self.listBox.insert(END, label%(i[1], i[0]))

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

if __name__ == "__main__":
    root = Tk()
    app = TestApplication(master=root)
    app.mainloop()
    root.destroy()