本文整理汇总了Python中pyjamas.ui.SimplePanel.SimplePanel.getWidget方法的典型用法代码示例。如果您正苦于以下问题:Python SimplePanel.getWidget方法的具体用法?Python SimplePanel.getWidget怎么用?Python SimplePanel.getWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.SimplePanel.SimplePanel
的用法示例。
在下文中一共展示了SimplePanel.getWidget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyjamas.ui.SimplePanel import SimplePanel [as 别名]
# 或者: from pyjamas.ui.SimplePanel.SimplePanel import getWidget [as 别名]
class Main:
def __init__(self, parent=None):
self.parent = RootPanel(parent)
self.screen = VerticalPanel(ID="aur-screen", Width="100%", Height="100%")
self.content = SimplePanel(ID="aur-content", Width="100%")
self.contentProvider = {}
self.contentCache = {}
self.contentActive = None
self.onLoad()
def setContentActive(self, target, cache_target=True, cache_use=True):
provider = self.contentProvider.get(target)
if provider is None:
provider = self.contentProvider.get(None)
if provider is None:
return False
cache = None
if cache_use:
cache = self.contentCache.get(target)
widget = provider(getattr(self, "content"), cache)
res = widget == self.content.getWidget()
if cache_target and res and self.contentCache.get(target) != widget:
self.contentCache[target] = widget
if res:
self.contentActive = target
return res
def setContentProvider(self, target, provider):
self.contentProvider[target] = provider
def onHistoryChanged(self):
self.setContentActive(History.getToken())
def onLoad(self):
History.addHistoryListener(self)
self.setContentProvider(None, home.provider)
self.setContentProvider("/home", home.provider)
self.setContentProvider("/account", underConstruction.provider)
self.setContentProvider("/package", underConstruction.provider)
self.setContentProvider("/package/search", searchResults.provider)
self.setContentProvider("/user", underConstruction.provider)
self.setContentProvider("/submit", underConstruction.provider)
self.draw()
def draw(self):
parent = self.parent
screen = self.screen
content = self.content
header = HorizontalPanel(ID="aur-header", Width="100%")
boundary = SimplePanel(ID="aur-boundary", StyleName="aur-link-stateful")
container = VerticalPanel(ID="aur-container", Width="100%", Height="100%")
parent.add(screen)
screen.add(header)
screen.setCellHeight(header, "1px")
screen.add(boundary)
boundary.add(container)
self.drawHeader(header)
self.drawBody(container)
self.onHistoryChanged()
def drawHeader(self, container):
logo = Image(
ID="aur-logo", url="http://www.archlinux.org/media/archnavbar/archlogo.gif", Width="190px", Height="40px"
)
menu = HorizontalPanel(ID="aur-menu-ext")
container.add(logo)
container.add(menu)
container.setCellWidth(menu, "1px")
self.drawExternalMenu(menu)
def drawBody(self, container):
menu = HorizontalPanel(ID="aur-menu-int")
search_cont = SimplePanel(StyleName="aur-content-boundary")
search = VerticalPanel(ID="aur-search")
footer = VerticalPanel(ID="aur-footer", Width="100%", HorizontalAlignment="center")
search_cont.add(search)
container.add(menu)
container.add(search_cont)
container.add(self.content)
container.add(footer)
container.setCellHeight(menu, "1px")
container.setCellHeight(footer, "1px")
container.setCellHorizontalAlignment(footer, "center")
self.drawInternalMenu(menu)
Search.draw(search)
self.drawFooter(footer)
def drawExternalMenu(self, container):
# we have to use HTML() widgets here for external links, no Anchor widget in pyjamas (yet) :-(
container.add(
HTML(
'<a href="http://www.archlinux.org/">Home</a>',
StyleName="aur-menu-ext-item",
Title="Arch news, projects, packages and more",
)
)
#.........这里部分代码省略.........