本文整理汇总了Python中pyjamas.History.getToken方法的典型用法代码示例。如果您正苦于以下问题:Python History.getToken方法的具体用法?Python History.getToken怎么用?Python History.getToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.History
的用法示例。
在下文中一共展示了History.getToken方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onModuleLoad
# 需要导入模块: from pyjamas import History [as 别名]
# 或者: from pyjamas.History import getToken [as 别名]
def onModuleLoad(self):
self.curInfo=''
self.curSink=None
self.description=HTML()
self.sink_list=SinkList()
self.panel=DockPanel()
self.loadSinks()
self.sinkContainer = DockPanel()
self.sinkContainer.setStyleName("ks-Sink")
vp=VerticalPanel()
vp.setWidth("100%")
vp.add(self.description)
vp.add(self.sinkContainer)
self.description.setStyleName("ks-Info")
self.panel.add(self.sink_list, DockPanel.WEST)
self.panel.add(vp, DockPanel.CENTER)
self.panel.setCellVerticalAlignment(self.sink_list, HasAlignment.ALIGN_TOP)
self.panel.setCellWidth(vp, "100%")
History.addHistoryListener(self)
RootPanel().add(self.panel)
RootPanel().add(Logger())
#Show the initial screen.
initToken = History.getToken()
if len(initToken):
self.onHistoryChanged(initToken)
else:
self.showInfo()
示例2: createPage
# 需要导入模块: from pyjamas import History [as 别名]
# 或者: from pyjamas.History import getToken [as 别名]
def createPage(self, title, purpose, text):
#log.debug("create page %s %s %s", title, purpose, text)
if purpose == 'faq':
self.faq_pages[title] = text
log.debug("%d %d", len(self.faq_pages), len(self.faq_list))
#log.debug(self.faq_pages.keys())
#log.debug(self.faq_list)
if len(self.faq_pages) != len(self.faq_list):
return
faq = self.page_widgets['FAQ']
for l in self.faq_list:
question = l[0]
answer = self.faq_pages[question]
html = faq.getHTML()
html += "<h3>%s</h3>\n" % question
html += "\n%s\n\n" % answer
faq.setHTML(html)
html = "<div class='faq'>\n%s</div>\n" % html
faq.setHTML(html)
faq.replaceLinks(use_page_href=False)
return
if title == 'header':
self.header.setHTML(text)
return
elif title == 'footer':
self.footer.setHTML(text)
return
elif title == 'sidebar':
self.sidebar.setHTML(text)
return
# Main content case - tabs etc.
self.pages[title] = text
if len(self.pages) != len(self.page_list):
return
self.page_widgets = {}
self.tab_index = {}
for (idx, l) in enumerate(self.page_list):
title = l[0]
text = self.pages[title]
self.tab_index[title] = idx
widget = HTMLLinkPanel(text)
self.fTabs.add(widget, title, True)
self.page_widgets[title] = widget
if title == 'FAQ':
HTTPRequest().asyncGet("faq/questions.txt",
PageListLoader(self, "faq"))
else:
widget.replaceLinks(use_page_href=False)
self.fTabs.selectTab(0)
History.addHistoryListener(self)
initToken = History.getToken()
log.debug("initial token: '%s'", initToken)
self.onHistoryChanged(initToken)
self.fTabs.addTabListener(self)
示例3: __init__
# 需要导入模块: from pyjamas import History [as 别名]
# 或者: from pyjamas.History import getToken [as 别名]
def __init__(self, format="%d-%m-%Y"):
self.format = format
self.tbox = TextBox()
self.tbox.setVisibleLength(10)
# assume valid sep is - / . or nothing
if format.find("-") >= 0:
self.sep = "-"
elif format.find("/") >= 0:
self.sep = "/"
elif format.find(".") >= 0:
self.sep = "."
else:
self.sep = ""
# self.sep = format[2] # is this too presumptious?
self.calendar = Calendar()
self.img = Image(self.icon_img)
self.img.addStyleName(self.icon_style)
self.calendarLink = HyperlinkImage(self.img, targetHistoryToken=History.getToken())
self.todayLink = Hyperlink(self.today_text, targetHistoryToken=History.getToken())
self.todayLink.addStyleName(self.today_style)
#
# lay it out
#
hp = HorizontalPanel()
hp.setSpacing(2)
vp = VerticalPanel()
hp.add(self.tbox)
vp.add(self.calendarLink)
vp.add(self.todayLink)
# vp.add(self.calendar)
hp.add(vp)
Composite.__init__(self)
self.initWidget(hp)
#
# done with layout, so now set up some listeners
#
self.tbox.addFocusListener(self) # hook to onLostFocus
self.calendar.addSelectedDateListener(getattr(self, "onDateSelected"))
self.todayLink.addClickListener(getattr(self, "onTodayClicked"))
self.calendarLink.addClickListener(getattr(self, "onShowCalendar"))
示例4: cast_off
# 需要导入模块: from pyjamas import History [as 别名]
# 或者: from pyjamas.History import getToken [as 别名]
def cast_off(self):
'''
sets up notifications to call App when page history changes.
@note: set-up Application's listeners and then call cast_off()
which will fire off the appropriate events to your app.
'''
self.timer_count = 0
self._set_history_listener(True, on_period=1)
token = History.getToken()
if len(token):
self.onHistoryChanged(token)
示例5: setChapters
# 需要导入模块: from pyjamas import History [as 别名]
# 或者: from pyjamas.History import getToken [as 别名]
def setChapters(self, chapters):
for l in chapters:
name = l[0]
desc = l[1]
self.sink_list.addSink(Chapter.init(name, desc))
#Show the initial screen.
initToken = History.getToken()
if len(initToken):
self.onHistoryChanged(initToken)
else:
self.showInfo()
示例6: __init__
# 需要导入模块: from pyjamas import History [as 别名]
# 或者: from pyjamas.History import getToken [as 别名]
def __init__(self):
self.remote = DataService()
self.title = Label()
self.h = WikiBox()
self.t = TextArea()
self.t.addKeyboardListener(self)
self.t.addChangeListener(self)
RootPanel().add(self.title)
RootPanel().add(self.h)
RootPanel().add(self.t)
History.addHistoryListener(self)
self.name = None
initToken = History.getToken()
if not (initToken and len(initToken)):
initToken = 'welcomepage'
self.onHistoryChanged(initToken)
示例7: onModuleLoad
# 需要导入模块: from pyjamas import History [as 别名]
# 或者: from pyjamas.History import getToken [as 别名]
def onModuleLoad(self):
self.remote = DataService()
#Show the initial screen.
initToken = History.getToken()
if initToken and len(initToken):
if initToken == 'admin':
RootPanel().add(WebPageEdit(self))
return
else:
initToken = 'index'
self.dock = DockPanel()
self.dock.setWidth("100%")
self.pages = {}
self.current_page = None
RootPanel().add(self.dock)
History.addHistoryListener(self)
self.onHistoryChanged(initToken)
示例8: onModuleLoad
# 需要导入模块: from pyjamas import History [as 别名]
# 或者: from pyjamas.History import getToken [as 别名]
def onModuleLoad(self):
dock = DockPanel()
self.header = HTML(Width="100%", Height="270px")
self.footer = HTML(Width="100%")
self.sidebar = HTML(Width="200px", Height="100%", StyleName="sidebar")
self.fTabs = DecoratedTabPanel(Size=("100%", "100%"),
StyleName="tabs")
#dp = DecoratorTitledPanel("Tabs", "bluetitle", "bluetitleicon",
# ["bluetop", "bluetop2", "bluemiddle", "bluebottom"])
#dp.add(self.fTabs)
dock.add(self.header, DockPanel.NORTH)
dock.add(self.footer, DockPanel.SOUTH)
dock.add(self.sidebar, DockPanel.EAST)
dock.add(self.fTabs, DockPanel.CENTER)
dock.setCellVerticalAlignment(self.fTabs, HasAlignment.ALIGN_TOP)
#dock.setCellHorizontalAlignment(self.fTabs, HasAlignment.ALIGN_CENTER)
dock.setCellWidth(self.header, "100%")
dock.setCellHeight(self.header, "270px")
dock.setCellWidth(self.footer, "100%")
dock.setCellWidth(self.sidebar, "200px")
History.addHistoryListener(self)
initToken = History.getToken()
#print "initial token", initToken
RootPanel().add(dock)
self.dock = dock
self.loadPageList()
Window.addWindowResizeListener(self)
DeferredCommand.add(self)
示例9: onHistoryChanged
# 需要导入模块: from pyjamas import History [as 别名]
# 或者: from pyjamas.History import getToken [as 别名]
def onHistoryChanged(self):
self.setContentActive(History.getToken())
示例10: onTabSelected
# 需要导入模块: from pyjamas import History [as 别名]
# 或者: from pyjamas.History import getToken [as 别名]
def onTabSelected(self, sender, tabIndex):
current_token = History.getToken()
new_token = self.page_list[tabIndex][0]
if current_token != new_token:
History.newItem(new_token)
示例11: drawControl
# 需要导入模块: from pyjamas import History [as 别名]
# 或者: from pyjamas.History import getToken [as 别名]
def drawControl(container):
bar = HorizontalPanel(ID='aur-search-bar', VerticalAlignment='middle')
adv = HorizontalPanel(ID='aur-search-advanced', Visible=False)
adv_toggle = Hyperlink(Text='Advanced', StyleName='aur-link-stateless aur-search-bar-advanced', TargetHistoryToken=History.getToken())
query = TextBox(Text='enter search term...', StyleName='aur-search-bar-query')
go = Button(HTML='Go', StyleName='aur-search-bar-submit')
container.add(bar)
container.add(adv)
# slight workaround to make sure the 'Advanced' toggle doesn't change the page
def updateAdvToken(token):
adv_toggle.setTargetHistoryToken(token)
obj = object()
setattr(obj, 'onHistoryChanged', updateAdvToken)
History.addHistoryListener(obj)
# clickListener to toggle the advanced section
def toggleAdv(sender):
if adv.isVisible():
adv.setVisible(False)
query.setEnabled(True)
adv_toggle.setText('Advanced')
else:
adv.setVisible(True)
query.setEnabled(False)
adv_toggle.setText('Basic')
adv_toggle.addClickListener(toggleAdv)
def doGo():
History.newItem('/package/search')
go.addClickListener(doGo)
bar.add(Label('Search Criteria', StyleName='aur-search-bar-label'))
bar.add(query)
bar.add(go)
bar.add(Button(HTML='Orphans', StyleName='aur-search-bar-submit'))
bar.add(adv_toggle)
drawAdvanced(adv)
示例12: drawFull
# 需要导入模块: from pyjamas import History [as 别名]
# 或者: from pyjamas.History import getToken [as 别名]
def drawFull(self, month, year):
# should be called only once when we draw the calendar for the first time
#
self.vp = VerticalPanel()
self.vp.setSpacing(2)
self.vp.addStyleName("calendarbox calendar-module calendar")
self.setWidget(self.vp)
self.setVisible(False)
#
mth = int(month)
yr = int(year)
tp = HorizontalPanel()
tp.addStyleName("calendar-top-panel")
tp.setSpacing(5)
h1 = Hyperlink("<<", targetHistoryToken=History.getToken())
h1.addClickListener(getattr(self, "onPreviousYear"))
h2 = Hyperlink("<", targetHistoryToken=History.getToken())
h2.addClickListener(getattr(self, "onPreviousMonth"))
h4 = Hyperlink(">", targetHistoryToken=History.getToken())
h4.addClickListener(getattr(self, "onNextMonth"))
h5 = Hyperlink(">>", targetHistoryToken=History.getToken())
h5.addClickListener(getattr(self, "onNextYear"))
tp.add(h1)
tp.add(h2)
# titlePanel can be changed, whenever we draw, so keep the reference
self.titlePanel = SimplePanel()
self.titlePanel.setWidget(HTML("<b>" + self.getMonthsOfYear()[mth - 1] + " " + str(yr) + "</b>"))
self.titlePanel.setStyleName("calendar-center")
tp.add(self.titlePanel)
tp.add(h4)
tp.add(h5)
tvp = VerticalPanel()
tvp.setSpacing(10)
tvp.add(tp)
self.vp.add(tvp)
# done with top panel
self.middlePanel = SimplePanel()
grid = self.drawGrid(mth, yr)
self.middlePanel.setWidget(grid)
self.vp.add(self.middlePanel)
self.defaultGrid = grid
#
# some links & handlers
#
bh1 = Hyperlink(self.yesterday, targetHistoryToken=History.getToken())
bh1.addClickListener(getattr(self, "onYesterday"))
bh2 = Hyperlink(self.today, targetHistoryToken=History.getToken())
bh2.addClickListener(getattr(self, "onToday"))
bh3 = Hyperlink(self.tomorrow, targetHistoryToken=History.getToken())
bh3.addClickListener(getattr(self, "onTomorrow"))
bh4 = Hyperlink(self.cancel, targetHistoryToken=History.getToken())
bh4.addClickListener(getattr(self, "onCancel"))
#
# add code to test another way of doing the layout
#
b = HorizontalPanel()
b.add(bh1)
b.add(bh2)
b.add(bh3)
b.addStyleName("calendar-shortcuts")
self.vp.add(b)
b2 = SimplePanel()
b2.add(bh4)
b2.addStyleName("calendar-cancel")
self.vp.add(b2)
self.setVisible(True)
return
示例13: showDL
# 需要导入模块: from pyjamas import History [as 别名]
# 或者: from pyjamas.History import getToken [as 别名]
def showDL(self):
Window.alert(History.getToken())