本文整理匯總了Python中pyjamas.History類的典型用法代碼示例。如果您正苦於以下問題:Python History類的具體用法?Python History怎麽用?Python History使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了History類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: onBrowserEvent
def onBrowserEvent(self, event):
Widget.onBrowserEvent(self, event)
event_type = DOM.eventGetType(event)
if event_type == "click":
DOM.eventPreventDefault(event)
if self.targetHistoryToken is not None:
History.newItem(self.targetHistoryToken)
示例2: __init__
def __init__(self, ):
self.__init__._super()
"""
Create showcase client.
"""
History.addValueChangeHandler(self)
self.outer.getElement().setId(u"ShowcaseClient")
self.showcaseWrapper.getElement().setId(u"ShowcaseWrapper")
self.horizontalSplit.setSpacing(10)
self.showcaseWrapper.setWidth(u"700px")
self.showcaseWrapper.addStyleName(u"showcaseWrapper")
self.treeMenu.addStyleName(u"treeMenu")
token = Window.Location.getHash()
if token == None or u"".equals(token):
self.doDisplayShowcase(self.__class__.DEFAULT_SHOW)
self.showcaseWrapper.insert(self.createDefaultFrontpage(), 0)
else:
self.doDisplayShowcase(token)
treeMenuWrapper = VerticalPanel()
treeMenuWrapper.addStyleName(u"treeMenuWrapper")
treeMenuWrapper.add(HTML(u"<h4>Methods: </h4>"))
treeMenuWrapper.add(self.treeMenu)
self.horizontalSplit.add(treeMenuWrapper) # Add left + right column
self.horizontalSplit.add(self.decorate(self.showcaseWrapper))
self.outer.add(self.horizontalSplit)
Xfbml.parse(self.outer)
self.initWidget(self.outer)
示例3: onModuleLoad
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()
示例4: onTimer
def onTimer(self, id):
'''
turn history listener on once all 'off' periods have completed
'''
self.timer_count += 1
if self.timer_count == 1:
History.addHistoryListener(self)
示例5: onSelection
def onSelection(self, event):
clickedLink = event.getSelectedItem()
if clickedLink.getChildCount() == 0:
if not self.apiClient.isSessionValid():
Window.alert(u"Your session has expired")
self.showcaseWrapper.clear()
else:
History.newItem(clickedLink.getText())
示例6: __init__
def __init__(self):
HorizontalPanel.__init__(self)
History.newItem("test")
show = Button("Show deep link", self.showDL)
setDL = Button("Set deep link to 'pyjamas'", self.setDL)
self.add(setDL)
self.add(show)
示例7: createPage
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)
示例8: onLoad
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()
示例9: __init__
def __init__(self):
SimplePanel.__init__(self)
History.addHistoryListener(self)
vPanel = VerticalPanel()
self.stateDisplay = Label()
vPanel.add(self.stateDisplay)
hPanel = HorizontalPanel(Spacing=5)
hPanel.add(Hyperlink("State 1", False, "state number 1"))
hPanel.add(Hyperlink("State 2", False, "state number 2"))
vPanel.add(hPanel)
self.add(vPanel)
示例10: loadChapters
def loadChapters(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")
#self.nf = NamedFrame("section")
#self.nf.setWidth("100%")
#self.nf.setHeight("10000")
height = Window.getClientHeight()
self.sp = ScrollPanel(self.sinkContainer)
#self.sp = VerticalSplitPanel()
self.sp.setWidth("100%")
self.sp.setHeight("%dpx" % (height-110))
#self.sp.setTopWidget(self.sinkContainer)
#self.sp.setBottomWidget(self.nf)
#self.sp.setSplitPosition(10000) # deliberately high - max out.
vp = VerticalPanel()
vp.setWidth("100%")
vp.setHeight("100%")
vp.add(self.description)
vp.add(self.sp)
self.description.setStyleName("ks-Intro")
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%")
self.panel.setCellHeight(vp, "100%")
Window.addWindowResizeListener(self)
History.addHistoryListener(self)
RootPanel().add(self.panel)
示例11: __init__
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)
示例12: _set_history_listener
def _set_history_listener(self, on, on_period=251):
'''
pyjamas/library/pyjamas/History.py is checking every 250ms if URL has changed
By default, BuoyService checks every 250+1ms before turning its listener back on.
An initial call in BuoyService() set-up needs to set on_period to 1 for immediate listening
Rapid UI-interaction can lead to multiple nested calls.
A count is kept to control when to add/remove the sole history listener.
If a count wasn't kept then History will wobble
'''
if on:
self.timer = Timer(on_period, self)
else:
if self.timer_count == 1:
History.removeHistoryListener(self)
self.timer_count -= 1
示例13: new_item
def new_item(self, token):
'''
updates the current URL's hash token.
disables the calling of BuoyService's onHistoryChanged() when a Buoy adds a new item
@param token: hash token
@type token: string
when an app is placed in a state by user interaction it calls Buoy.drop_anchor()
which calls BuoyService.new_item(). The subsequent call to History.newItem() will call
BuoyService.onHistoryChanged() but as the app is already in the correct state
there is such requirement. So we smoother it by disabling BuoyService's history listener
until after the new item is added.
'''
self._set_history_listener(False)
History.newItem(token)
self._set_history_listener(True)
示例14: show
def show(self, info, affectHistory=None):
if info == self.curInfo: return
self.curInfo = info
if self.curSink <> None:
self.curSink.onHide()
self.sinkContainer.remove(self.curSink)
self.curSink = info.getInstance()
self.sink_list.setSinkSelection(info.getName())
self.description.setHTML(info.getDescription())
if (affectHistory):
History.newItem(info.getName())
self.sinkContainer.add(self.curSink, DockPanel.CENTER)
self.sinkContainer.setCellWidth(self.curSink, "100%")
self.sinkContainer.setCellHeight(self.curSink, "100%")
self.sinkContainer.setCellVerticalAlignment(self.curSink, HasAlignment.ALIGN_TOP)
self.curSink.onShow()
示例15: __init__
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"))