本文整理匯總了Python中HTML.HTML.getElement方法的典型用法代碼示例。如果您正苦於以下問題:Python HTML.getElement方法的具體用法?Python HTML.getElement怎麽用?Python HTML.getElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類HTML.HTML
的用法示例。
在下文中一共展示了HTML.getElement方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: DialogBox
# 需要導入模塊: from HTML import HTML [as 別名]
# 或者: from HTML.HTML import getElement [as 別名]
class DialogBox(PopupPanel):
def __init__(self, autoHide=None, modal=True, **kwargs):
PopupPanel.__init__(self, autoHide, modal, **kwargs)
self.caption = HTML()
self.child = None
self.dragging = False
self.dragStartX = 0
self.dragStartY = 0
self.panel = FlexTable(Height="100%", BorderWidth="0",
CellPadding="0", CellSpacing="0")
self.panel.setWidget(0, 0, self.caption)
self.panel.getCellFormatter().setHeight(1, 0, "100%")
self.panel.getCellFormatter().setWidth(1, 0, "100%")
self.panel.getCellFormatter().setAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE)
PopupPanel.setWidget(self, self.panel)
self.setStyleName("gwt-DialogBox")
self.caption.setStyleName("Caption")
self.caption.addMouseListener(self)
def getHTML(self):
return self.caption.getHTML()
def getText(self):
return self.caption.getText()
def onEventPreview(self, event):
# preventDefault on mousedown events, outside of the
# dialog, to stop text-selection on dragging
type = DOM.eventGetType(event)
if type == 'mousedown':
target = DOM.eventGetTarget(event)
elem = self.caption.getElement()
event_targets_popup = target and DOM.isOrHasChild(elem, target)
if event_targets_popup:
DOM.eventPreventDefault(event)
return PopupPanel.onEventPreview(self, event)
def onMouseDown(self, sender, x, y):
self.dragging = True
DOM.setCapture(self.caption.getElement())
self.dragStartX = x
self.dragStartY = y
def onMouseEnter(self, sender):
pass
def onMouseLeave(self, sender):
pass
def onMouseMove(self, sender, x, y):
if self.dragging:
absX = x + self.getAbsoluteLeft()
absY = y + self.getAbsoluteTop()
self.setPopupPosition(absX - self.dragStartX, absY - self.dragStartY)
def onMouseUp(self, sender, x, y):
self.dragging = False
DOM.releaseCapture(self.caption.getElement())
def remove(self, widget):
if self.child != widget:
return False
self.panel.remove(widget)
self.child = None
return True
def setHTML(self, html):
self.caption.setHTML(html)
def setText(self, text):
self.caption.setText(text)
def doAttachChildren(self):
PopupPanel.doAttachChildren(self)
self.caption.onAttach()
def doDetachChildren(self):
PopupPanel.doDetachChildren(self)
self.caption.onDetach()
def setWidget(self, widget):
if self.child is not None:
self.panel.remove(self.child)
if widget is not None:
self.panel.setWidget(1, 0, widget)
self.child = widget