PageRenderTime 24ms CodeModel.GetById 12ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/examples/addonsgallery/AutoCompleteTab.py

http://pyjamas.googlecode.com/
Python | 28 lines | 19 code | 8 blank | 1 comment | 0 complexity | f6b46f736d6c761891d03b59b0484a52 MD5 | raw file
 1from Sink import Sink, SinkInfo
 2from ui import Image, HTML, VerticalPanel, HorizontalPanel
 3from AutoComplete import AutoCompleteTextBox
 4
 5class AutoCompleteTab(Sink):
 6    def __init__(self):
 7        colours = ['Azure', 'Red', 'Rust', 'Green', 'Beige', 'Brass', 'Brown', 'Bronze', 'Blue', 'Black', 'Burgundy', 'Pink', 'Gold', 'Gray', 'Purple', 'Yellow', 'White']
 8        
 9        self.colour_input = AutoCompleteTextBox()
10        self.colour_input.setCompletionItems(colours)
11        
12        panel = HorizontalPanel()
13        panel.add(HTML("Enter a colour: "))
14        panel.add(self.colour_input)
15
16        panel.setSpacing(8)
17        self.setWidget(panel)
18        
19
20    def onShow(self):
21        #self.colour_input.setFocus(True)
22        return
23
24
25def init():
26    text="<b>Text field auto-completion component</b><p>Shows a list of matching items as you type. Items can be selected with keyboard or mouse."
27    text+=r"<p>Originally by Oliver Albers at <a href=\"http://gwt.components.googlepages.com\">gwt.components.googlepages.com</a>"
28    return SinkInfo("AutoComplete", text, AutoCompleteTab)