PageRenderTime 122ms CodeModel.GetById 81ms app.highlight 5ms RepoModel.GetById 35ms app.codeStats 0ms

/examples/kitchensink/Menus.py

http://pyjamas.googlecode.com/
Python | 45 lines | 34 code | 11 blank | 0 comment | 0 complexity | 1e4c77a4156b80ff42ebcb16d0db1772 MD5 | raw file
 1from Sink import Sink, SinkInfo
 2from ui import MenuBar, MenuItem
 3import Window
 4
 5class Menus(Sink):
 6    def __init__(self):
 7        self.menu = MenuBar()
 8        
 9        subMenu = MenuBar(True)
10        subMenu.addItem("<code>Code</code>", True, self)
11        subMenu.addItem("<strike>Strikethrough</strike>", True, self)
12        subMenu.addItem("<u>Underlined</u>", True, self)
13        
14        menu0 = MenuBar(True)
15        menu0.addItem("<b>Bold</b>", True, self)
16        menu0.addItem("<i>Italicized</i>", True, self)
17        menu0.addItem("More &#187;", True, subMenu)
18        menu1 = MenuBar(True)
19        menu1.addItem("<font color='#FF0000'><b>Apple</b></font>", True, self)
20        menu1.addItem("<font color='#FFFF00'><b>Banana</b></font>", True, self)
21        menu1.addItem("<font color='#FFFFFF'><b>Coconut</b></font>", True, self)
22        menu1.addItem("<font color='#8B4513'><b>Donut</b></font>", True, self)
23        menu2 = MenuBar(True)
24        menu2.addItem("Bling", self)
25        menu2.addItem("Ginormous", self)
26        menu2.addItem("<code>w00t!</code>", True, self)
27        
28        self.menu.addItem(MenuItem("Style", menu0))
29        self.menu.addItem(MenuItem("Fruit", menu1))
30        self.menu.addItem(MenuItem("Term", menu2))
31        
32        self.menu.setWidth("100%")
33        
34        self.initWidget(self.menu)
35
36
37    def execute(self):
38        Window.alert("Thank you for selecting a menu item.")
39        
40    def onShow(self):
41        pass
42
43
44def init():
45    return SinkInfo("Menus", "The GWT <code>MenuBar</code> class makes it easy to build menus, including cascading sub-menus.", Menus)