PageRenderTime 37ms CodeModel.GetById 33ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/examples/addonsgallery/SinkList.py

http://pyjamas.googlecode.com/
Python | 37 lines | 29 code | 8 blank | 0 comment | 7 complexity | 514c1d5ef5f24ed28d12a8fff0e057ba MD5 | raw file
 1from ui import Composite, VerticalPanel, Hyperlink
 2
 3class SinkList(Composite):
 4    def __init__(self):
 5        self.vp_list=VerticalPanel()
 6        self.sinks=[]
 7        self.selectedSink=-1
 8        
 9        self.setWidget(self.vp_list)
10        self.setStyleName("ks-List")
11
12    def addSink(self, info):
13        name = info.getName()
14        link = Hyperlink(name, False, name)
15        link.setStyleName("ks-SinkItem")
16        self.vp_list.add(link)
17        self.sinks.append(info)
18
19    def find(self, sinkName):
20        for info in self.sinks:
21            if info.getName()==sinkName:
22                return info
23        return None
24
25    def setSinkSelection(self, name):
26        if self.selectedSink <> -1:
27            self.vp_list.getWidget(self.selectedSink).removeStyleName("ks-SinkItem-selected")
28
29        for i in range(len(self.sinks)):
30            info = self.sinks[i]
31            if (info.getName()==name):
32                self.selectedSink = i
33                widget=self.vp_list.getWidget(self.selectedSink)
34                widget.addStyleName("ks-SinkItem-selected")
35                return
36
37