本文整理汇总了Python中pyjamas.ui.TextBox.TextBox.getElement方法的典型用法代码示例。如果您正苦于以下问题:Python TextBox.getElement方法的具体用法?Python TextBox.getElement怎么用?Python TextBox.getElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.TextBox.TextBox
的用法示例。
在下文中一共展示了TextBox.getElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: InputControl
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import getElement [as 别名]
class InputControl(Control):
def __init__(self, min_value, max_value, start_value=None, step=None,
**kwargs):
if not kwargs.has_key("StyleName"):
kwargs['StyleName'] = "gwt-InputControl"
self.input = TextBox()
self.input.addKeyboardListener(self)
#element = DOM.createDiv()
if kwargs.has_key('Element'):
# XXX FIXME: unlikely to work!
element = kwargs.pop('Element')
else:
element = self.input.getElement() # YUK!!!
Control.__init__(self, element, min_value, max_value, start_value, step,
**kwargs)
self.addClickListener(self)
self.addFocusListener(self)
self.addKeyboardListener(self)
def onFocus(self, sender):
self.addStyleName("gwt-InputControl-focussed")
def onLostFocus(self, sender):
self.removeStyleName("gwt-InputControl-focussed")
def setControlPos(self, value):
self.input.setText(value)
def onKeyPress(self, sender, keycode, modifiers):
if keycode == KeyboardListener.KEY_ENTER:
DOM.eventPreventDefault(DOM.eventGetCurrentEvent())
txt = self.input.getText()
if not txt:
return
new_value = float(txt)
new_value = self.processValue(new_value)
self.setControlPos(new_value)
self.setValue(new_value)
else:
Control.onKeyPress(self, sender, keycode, modifiers)