本文整理汇总了Python中pyjamas.ui.HTML.HTML.addClickListener方法的典型用法代码示例。如果您正苦于以下问题:Python HTML.addClickListener方法的具体用法?Python HTML.addClickListener怎么用?Python HTML.addClickListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.HTML.HTML
的用法示例。
在下文中一共展示了HTML.addClickListener方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import addClickListener [as 别名]
def __init__(self, grid_size):
Grid.__init__(self)
# populate the grid with some stuff
#
self.resize(grid_size, grid_size)
self.setBorderWidth(2)
self.setCellPadding(4)
self.setCellSpacing(1)
self.setStyleName("gameboard") # just doesn't work
# Set up game board
#
# Note that must iterate over indices, rather than Cell
# instances, until the table positions are set up here
#
index = 0 # debug
for i in range(grid_size):
for j in range(grid_size):
cell = HTML(SPACE)
# cell.setVisible(False) # causes to ignore click events
cell.position = (i, j) # might be handy at some point
index+=1; cell.index = index # debug
# cell.setStyleName("cell_O")
cell.addClickListener(getattr(self, "onCellClicked"))
self.setWidget(i, j, cell)
示例2: addContact
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import addClickListener [as 别名]
def addContact(self, contact):
link = HTML("<a href='javascript:;'>" + contact.name + "</a>")
self.panel.add(link)
# Add a click listener that displays a ContactPopup when it is clicked.
listener = ContactListener(contact, link)
link.addClickListener(listener)
示例3: __init__
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import addClickListener [as 别名]
def __init__(self, txt, **kwargs):
txt = HTML(txt)
txt.addClickListener(self)
PopupPanel.__init__(self, autoHide=True, StyleName="showcase-popup",
**kwargs)
self.add(txt)
self.show()
示例4: showPopup
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import addClickListener [as 别名]
def showPopup(self, event):
contents = HTML("Hello, World!")
contents.addClickListener(getattr(self, "onClick"))
self._popup = PopupPanel(autoHide=True)
self._popup.add(contents)
self._popup.setStyleName("showcase-popup")
left = self._btn.getAbsoluteLeft() + 10
top = self._btn.getAbsoluteTop() + 10
self._popup.setPopupPosition(left, top)
self._popup.show()
示例5: TopPanel
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import addClickListener [as 别名]
class TopPanel(Composite):
def __init__(self):
Composite.__init__(self)
self.signOutLink = HTML("<a href='javascript:;'>Sign Out</a>")
self.aboutLink = HTML("<a href='javascript:;'>About</a>")
outer = HorizontalPanel()
inner = VerticalPanel()
outer.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT)
inner.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT)
links = HorizontalPanel()
links.setSpacing(4)
links.add(self.signOutLink)
links.add(self.aboutLink)
outer.add(inner)
inner.add(HTML("<b>Welcome back, [email protected]</b>"))
inner.add(links)
self.signOutLink.addClickListener(self)
self.aboutLink.addClickListener(self)
self.initWidget(outer)
inner.setStyleName("mail-TopPanel")
links.setStyleName("mail-TopPanelLinks")
def onClick(self, sender):
if (sender == self.signOutLink):
Window.alert("If this were implemented, you would be signed out now.")
elif (sender == self.aboutLink):
# When the 'About' item is selected, show the AboutDialog.
# Note that showing a dialog box does not block -- execution continues
# normally, and the dialog fires an event when it is closed.
dlg = AboutDialog()
# Position it roughly in the middle of the screen.
left = (Window.getClientWidth() - 512) / 2
top = (Window.getClientHeight() - 256) / 2
Logger("TopPanel", "left: %d" % left)
Logger("TopPanel", "top: %d" % top)
dlg.setPopupPosition(left, top)
dlg.show()
示例6: PrettyTab
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import addClickListener [as 别名]
class PrettyTab(Composite):
def __init__(self, text, imageUrl):
DecoratorPanel.__init__(self, DecoratorPanel.DECORATE_ALL)
p = HorizontalPanel()
p.setSpacing(3)
self.img = Image(imageUrl)
self.txt = HTML(text)
p.add(self.img)
p.add(self.txt)
self.add(p)
def addClickListener(self, listener):
self.img.addClickListener(listener)
self.txt.addClickListener(listener)
示例7: addRow
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import addClickListener [as 别名]
def addRow(self,Entry,r, row):
#Window.alert(r['thumbimg'])
title = HTML("<span title=\""+r['title']+"\"; style=\"color:black;\">"+r['title']+"</span>")
title.setStyleName("pointer")
author = HTML("<span title=\""+r['author']+"\" style=\"color:grey\">"+"Author(s): "+r['author']+"</span>")
#asin = r['asin']
img = r['thumbnail']
nsellers = HTML("<span style=\"color:green\">"+"Sellers: "+str(r['numsellers'])+"</span>")
isbn = HTML("<span style=\"color:#483D8B\">"+"ISBN: "+str(r['isbn'])+"</span>")
onSell = r['onSell']
onWish = r['onWish']
if(img == "N/A"):
img = "#"
imghtml = HTML("<img src='"+img+"' alt='No Thumbnail'/>")
imghtml.setStyleName("pointer")
title.setWidth(str(self.table_width)+"px")
author.setWidth(str(self.table_width)+"px")
info_wrapper = VerticalPanel()
info_wrapper.add(title)
info_wrapper.add(isbn)
info_wrapper.add(author)
info_wrapper.add(nsellers)
Entry.setWidget(row,0,imghtml)
Entry.setWidget(row, 1, info_wrapper)
Entry.getRowFormatter().addStyleName(row,"comments")
#Entry.setWidget(row,1,title)
#Entry.setText(row,2,nsellers)
def _get_book_data_Click(event):
self.remote.search_check(self,r)
title.addClickListener(_get_book_data_Click)
title.addStyleName("pointer")
imghtml.addClickListener(_get_book_data_Click)
imghtml.addStyleName("pointer")
'''
示例8: __init__
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import addClickListener [as 别名]
def __init__(self, worksheet, id):
SimplePanel.__init__(self)
MouseHandler.__init__(self)
self._id = id
self._worksheet = worksheet
insert_new_cell = HTML("", StyleName="insert_new_cell")
insert_new_cell.addClickListener(InsertListener(worksheet, self._id))
input_prompt = HTML("In [%d]:" % self._id, Element=DOM.createSpan(),
StyleName="input_prompt")
cell_input = InputArea(worksheet, self._id, StyleName='cell_input')
evaluate_button = HTML("evaluate", Element=DOM.createAnchor(),
StyleName="eval_button", Visible=False)
evaluate_button.getElement().setAttribute("href", "")
evaluate_button.addClickListener(EvaluateListener(self))
evaluate_button.addMouseListener(self)
output_delimiter = HTML("", StyleName="output_delimiter")
output_prompt = HTML("Out[%d]:" % self._id, Element=DOM.createSpan(),
StyleName="output_prompt")
cell_output = HTML("", Element=DOM.createSpan(),
StyleName="cell_output")
output_prompt.setVisible(False)
p = FlowPanel(StyleName="cell")
p.add(insert_new_cell)
p.add(input_prompt)
p.add(cell_input)
p.add(evaluate_button)
p.add(output_delimiter)
p.add(output_prompt)
p.add(cell_output)
self.add(p)
self._cell_input = cell_input
self._cell_output = cell_output
self._output_prompt = output_prompt
self._evaluate_button = evaluate_button
self._mouse_in = False
示例9: MailList
# 需要导入模块: from pyjamas.ui.HTML import HTML [as 别名]
# 或者: from pyjamas.ui.HTML.HTML import addClickListener [as 别名]
class MailList(Composite):
VISIBLE_EMAIL_COUNT = 10
def __init__(self, mailObject):
Composite.__init__(self)
self.countLabel = HTML()
self.newerButton = HTML("<a href='javascript:;'>< newer</a>", True)
self.olderButton = HTML("<a href='javascript:;'>older ></a>", True)
self.startIndex = 0
self.selectedRow = -1
self.table = FlexTable()
self.navBar = HorizontalPanel()
self.mailObject = mailObject
# Setup the table.
self.table.setCellSpacing(0)
self.table.setCellPadding(2)
self.table.setWidth("100%")
# Hook up events.
self.table.addTableListener(self)
self.newerButton.addClickListener(self)
self.olderButton.addClickListener(self)
# Create the 'navigation' bar at the upper-right.
innerNavBar = HorizontalPanel()
innerNavBar.setSpacing(8)
innerNavBar.add(self.newerButton)
innerNavBar.add(self.countLabel)
innerNavBar.add(self.olderButton)
self.navBar.setStyleName("mail-ListNavBar")
self.navBar.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT)
self.navBar.add(innerNavBar)
self.navBar.setWidth("100%")
self.initWidget(self.table)
self.setStyleName("mail-List")
self.initTable()
self.update()
def onCellDoubleClicked(self, sender, row, cell):
pass
def onCellClicked(self, sender, row, cell):
# Select the row that was clicked (-1 to account for header row).
if (row > 0):
self.selectRow(row - 1)
def onClick(self, sender):
if (sender == self.olderButton):
# Move forward a page.
self.startIndex = self.startIndex + MailList.VISIBLE_EMAIL_COUNT
if (self.startIndex >= MailItems().getMailItemCount()):
self.startIndex = self.startIndex - MailList.VISIBLE_EMAIL_COUNT
else:
self.styleRow(self.selectedRow, False)
self.selectedRow = -1
self.update()
elif (sender == self.newerButton):
# Move back a page.
self.startIndex = self.startIndex - MailList.VISIBLE_EMAIL_COUNT
if (self.startIndex < 0):
self.startIndex = 0
else:
self.styleRow(self.selectedRow, False)
self.selectedRow = -1
self.update()
def initTable(self):
# Create the header row.
self.table.setText(0, 0, "sender")
self.table.setText(0, 1, "email")
self.table.setText(0, 2, "subject")
self.table.setWidget(0, 3, self.navBar)
self.table.getRowFormatter().setStyleName(0, "mail-ListHeader")
# Initialize the rest of the rows.
i = 0
while i < MailList.VISIBLE_EMAIL_COUNT:
self.table.setText(i + 1, 0, "")
self.table.setText(i + 1, 1, "")
self.table.setText(i + 1, 2, "")
self.table.getCellFormatter().setWordWrap(i + 1, 0, False)
self.table.getCellFormatter().setWordWrap(i + 1, 1, False)
self.table.getCellFormatter().setWordWrap(i + 1, 2, False)
self.table.getFlexCellFormatter().setColSpan(i + 1, 2, 2)
i = i + 1
def selectRow(self, row):
# When a row (other than the first one, which is used as a header) is
# selected, display its associated MailItem.
item = MailItems().getMailItem(self.startIndex + row)
if item is None:
return
#.........这里部分代码省略.........