本文整理汇总了Python中BaseWidget.BaseWidget.set_focus方法的典型用法代码示例。如果您正苦于以下问题:Python BaseWidget.set_focus方法的具体用法?Python BaseWidget.set_focus怎么用?Python BaseWidget.set_focus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseWidget.BaseWidget
的用法示例。
在下文中一共展示了BaseWidget.set_focus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_focus
# 需要导入模块: from BaseWidget import BaseWidget [as 别名]
# 或者: from BaseWidget.BaseWidget import set_focus [as 别名]
def set_focus (self, focus=True):
"""E.set_focus (...) -> bool
Sets the input and action focus of the Editable.
Sets the input and action focus of the Editable and returns True
upon success or False, if the focus could not be set.
Note: This method only works as supposed using
a render loop, which supports the Renderer class specification.
"""
if not self.sensitive:
return False
BaseWidget.set_focus (self, focus)
if focus:
# Save the text after activation and reset the caret blink
# effects.
self._caret_visible = True
self._temp = self.text
self._caret_visible = True
self._counter = 0
self.state = STATE_ACTIVE
elif self._temp != self.text:
# If the Editable looses its input focus _and_ has changed text,
# it will be validated by default.
if base.debug: print "Editable.INPUT"
self._temp = self.text
self.state = STATE_NORMAL
self.run_signal_handlers (SIG_INPUT)
else:
# The Editable looses its input focus without any change.
self.state = STATE_NORMAL
self._caret = 0
return True