本文整理汇总了Python中pyjamas.ui.HorizontalPanel.HorizontalPanel.clear方法的典型用法代码示例。如果您正苦于以下问题:Python HorizontalPanel.clear方法的具体用法?Python HorizontalPanel.clear怎么用?Python HorizontalPanel.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.HorizontalPanel.HorizontalPanel
的用法示例。
在下文中一共展示了HorizontalPanel.clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyjamas.ui.HorizontalPanel import HorizontalPanel [as 别名]
# 或者: from pyjamas.ui.HorizontalPanel.HorizontalPanel import clear [as 别名]
class pjBallot:
def __init__(self):
self.mainPanel = VerticalPanel()
self.contest = HorizontalPanel()
self.contest.setStyleName('words')
self.selection = HorizontalPanel()
self.selection.setStyleName('words')
self.button = Button('test', self.test)
self.x = 1
def test(self):
self.button.setText("No, really click me!")
# Window.alert("Hello, AJAAAX!")
self.contest.add(HTML('yay'))
def nextContest(self):
self.x += 1
self.contest.clear()
self.contest.add(HTML('<b /> Contest: %d' % self.x))
def nextSelection(self):
self.x += 1
self.selection.clear()
self.selection.add(HTML('<b /> Selection: %d' % self.x))
def onKeyDown(self, sender, keycode, modifiers):
pass
def onKeyUp(self, sender, keycode, modifiers):
pass
def onKeyPress(self, sender, keycode, modifiers):
DOM.eventPreventDefault(DOM.eventGetCurrentEvent()) #not needed
if keycode == KeyboardListener.KEY_UP:
self.nextContest()
if keycode == KeyboardListener.KEY_DOWN:
self.nextContest()
if keycode == KeyboardListener.KEY_LEFT:
self.nextSelection()
if keycode == KeyboardListener.KEY_RIGHT:
self.nextSelection()
def onModuleLoad(self):
h = HTML("<b />Contest: ")
self.contest.add(h)
l = HTML("<b />Selection: ")
self.selection.add(l)
# self.mainPanel.add(self.button)
self.mainPanel.add(self.contest)
self.mainPanel.add(self.selection)
panel = FocusPanel(Widget=self.mainPanel)
gp = RootPanelListener(panel)
manageRootPanel(gp)
RootPanel().add(panel)
panel.setFocus(True)
示例2: onModuleLoad
# 需要导入模块: from pyjamas.ui.HorizontalPanel import HorizontalPanel [as 别名]
# 或者: from pyjamas.ui.HorizontalPanel.HorizontalPanel import clear [as 别名]
class Navigate:
def onModuleLoad(self):
self.crumbs = HorizontalPanel(StyleName='breadcrumbs')
self.crumbs.add(HTML('Home'))
RootPanel().add(self.crumbs)
self.buoy = BuoyService('Navigator', crumb='Home')
self.buoy.add_flare_listener(self)
self.buoy.set_titles_listener(self)
self.buoy.set_breadcrumbs_listener(self)
self.toplevel = TopNav()
self.toplevel.set(self.buoy)
self.buoy.cast_off()
RootPanel().add(self.toplevel)
def onFlare(self, service, prefixes):
if self.toplevel:
self.toplevel.set(service)
def onTitlesChanged(self, titles):
browser_title = ''
for title in reversed(titles):
browser_title += title + ' - '
browser_title = browser_title[:-3]
Window.setTitle(browser_title)
def onBreadcrumbsChanged(self, crumbs):
self.crumbs.clear()
for n, crumb in enumerate(crumbs):
if n < len(crumbs) - 1:
self.crumbs.add(Hyperlink(text=crumb['label'], TargetHistoryToken=crumb['token']))
self.crumbs.add(Label('>'))
else:
self.crumbs.add(HTML('<b>%s</b>' % crumb['label']))
示例3: LargeQueryTab
# 需要导入模块: from pyjamas.ui.HorizontalPanel import HorizontalPanel [as 别名]
# 或者: from pyjamas.ui.HorizontalPanel.HorizontalPanel import clear [as 别名]
class LargeQueryTab(TickeryTab):
# Define these in subclasses
instructions = None
instructionsTitle = None
tabName = None
defaultQuery = None
def __init__(self, topPanel):
TickeryTab.__init__(self, topPanel)
# Get the query string and wanted tab, if any, from URL args.
args = Window.getLocation().getSearchDict()
query = args.get('query')
wantedTab = args.get('tab')
if wantedTab:
wantedTab = wantedTab.lower()
if query and wantedTab == self.tabName.lower():
query = urllib.unquote_plus(query)
self.autoActivate = True
else:
query = self.defaultQuery
self.instructions.setHorizontalAlignment(HasAlignment.ALIGN_LEFT)
self.instructions.setStyleName('instructions-popup')
self.popup = InstructionBox(
self.__class__.__name__, self.instructions)
self.popup.setText(self.instructionsTitle)
self.db = Button(HELP_TEXT, StyleName='help-button')
self.db.addClickListener(self)
huhId = HTMLPanel.createUniqueId()
help = HTMLPanel('%s <span id="%s"></span>' %
(SHORT_INSTRUCTIONS[self.tabName], huhId),
StyleName='simple-instructions')
help.add(self.db, huhId)
self.goButton = go.GoButton(self)
self.query = text.TextAreaFocusHighlight(Text=query,
VisibleLines=3,
StyleName='large-query-area')
self.checkResult = HorizontalPanel(Spacing=4)
mainGrid = Grid(2, 2, StyleName='tickery-tab-panel',
HorizontalAlignment=HasAlignment.ALIGN_LEFT)
formatter = mainGrid.getCellFormatter()
mainGrid.setWidget(0, 0, help)
mainGrid.setWidget(1, 0, self.query)
mainGrid.setWidget(1, 1, self.goButton)
formatter.setHorizontalAlignment(0, 0, 'left')
formatter.setHorizontalAlignment(1, 0, 'left')
formatter.setAlignment(1, 1, 'left', 'bottom')
self.topGrid.setWidget(0, 1, mainGrid)
self.add(self.checkResult)
self.results = userlist.UserListPanel(self, topPanel,
HorizontalAlignment=HasAlignment.ALIGN_LEFT)
self.add(self.results)
def setInputFocus(self):
self.query.setFocus(True)
def clearResults(self):
self.results.clear()
def clearCheckResult(self):
self.checkResult.clear()
def onClick(self, sender):
if sender == self.db:
width = (Window.getClientWidth() - POPUP_WIDTH) / 2.0
self.popup.setPopupPosition(width, 100)
self.popup.show()
else:
self.process()
def process(self):
self.clearCheckResult()
self.clearResults()
text = self.query.getText()
query = text.strip()
if query:
self.query.setCursorPos(len(text))
self.goButton.setEnabled(False)
checkWidget = results.ResultHandler(
query, self, self.tabName, titleMaker)
remote = server.TickeryService()
f = getattr(remote, self.goButtonRemoteMethod)
id = f(self.topPanel.loginPanel.oauthCookie,
self.tabName, query, checkWidget)
if id < 0:
self.checkResult.add(Label('oops!',
StyleName='userlist-error-title'))
else:
self.checkResult.add(Label('Try a non-empty query!',
StyleName='userlist-error-title'))
def resultsLink(self):
d = {
'query' : self.query.getText().strip(),
'sort' : userlist._sortKey,
#.........这里部分代码省略.........