PageRenderTime 344ms CodeModel.GetById 181ms app.highlight 4ms RepoModel.GetById 157ms app.codeStats 1ms

/examples/mail/Mailboxes.py

http://pyjamas.googlecode.com/
Python | 27 lines | 22 code | 5 blank | 0 comment | 0 complexity | 87c9902e03b3c8ecdd127545a3e51a12 MD5 | raw file
 1from ui import Composite, Tree, TreeItem
 2
 3    
 4class Mailboxes(Composite):
 5    def __init__(self):
 6        self.tree = Tree()
 7        root = TreeItem(self.imageItemHTML("home.gif", "foo@example.com"))
 8        self.tree.addItem(root)     
 9        inboxItem = self.addImageItem(root, "Inbox")
10        self.addImageItem(root, "Drafts")
11        self.addImageItem(root, "Templates")
12        self.addImageItem(root, "Sent")
13        self.addImageItem(root, "Trash")
14
15        root.setState(True)
16        self.initWidget(self.tree)
17
18    def addImageItem(self, root, title):
19        item = TreeItem(self.imageItemHTML(title + ".gif", title))
20        root.addItem(item)
21        return item
22
23    def imageItemHTML(self, imageUrl, title):
24        value  = "<span><img style='margin-right:4px' src='"
25        value += "http://code.google.com/webtoolkit/documentation/examples/desktopclone/"
26        value += imageUrl.toLowerCase() + "'>" + title + "</span>"
27        return value