PageRenderTime 186ms CodeModel.GetById 149ms app.highlight 4ms RepoModel.GetById 22ms app.codeStats 0ms

/examples/kitchensink/SinkList.py

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