Statistiques
| Révision :

root / prepareQMX.GUI.py @ 6

Historique | Voir | Annoter | Télécharger (1,26 ko)

1
#!/usr/bin/env python
2
from Tkinter import *
3

    
4

    
5
class ScrolledList(Frame):
6
    def __init__(self, options, parent=None):
7
        Frame.__init__(self, parent)
8
        self.pack(expand=YES, fill=BOTH)                  
9
        self.makeWidgets(options)
10
        
11
    def handleList(self, event):
12
        index = self.listbox.curselection()            
13
        label = self.listbox.get(index)                
14
        self.runCommand(label)                         
15

    
16
    def makeWidgets(self, options):                    
17
        sbar = Scrollbar(self)
18
        list = Listbox(self, relief=SUNKEN)
19
        sbar.config(command=list.yview)                
20
        list.config(yscrollcommand=sbar.set)              
21
        sbar.pack(side=RIGHT, fill=Y)                     
22
        list.pack(side=LEFT, expand=YES, fill=BOTH)    
23
        pos = 0
24
        for label in options:                          
25
            list.insert(pos, label)                    
26
            pos = pos + 1
27

    
28
        list.bind('<Double-1>', self.handleList)       
29
        self.listbox = list
30
    def runCommand(self, selection):                   
31
        print 'You selected:', selection
32

    
33
if __name__ == '__main__':
34
    options = map((lambda x: 'Lumberjack-' + str(x)), range(20))
35
    ScrolledList(options).mainloop()