本文整理汇总了Python中kiwi.ui.widgets.entry.ProxyEntry.get_position方法的典型用法代码示例。如果您正苦于以下问题:Python ProxyEntry.get_position方法的具体用法?Python ProxyEntry.get_position怎么用?Python ProxyEntry.get_position使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kiwi.ui.widgets.entry.ProxyEntry
的用法示例。
在下文中一共展示了ProxyEntry.get_position方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EditorPropertyName
# 需要导入模块: from kiwi.ui.widgets.entry import ProxyEntry [as 别名]
# 或者: from kiwi.ui.widgets.entry.ProxyEntry import get_position [as 别名]
class EditorPropertyName(EditorProperty):
duplicate_name_msg = _("There is already a widget with this name")
no_name_msg = _("The widget must have a name")
def __init__(self, property_class, app):
EditorProperty.__init__(self, property_class, app)
self.input = ProxyEntry()
self.input.set_property('data-type', str)
self.input.connect('changed', self._changed_text)
def load(self, widget):
self._start_load(widget)
self._internal_load(widget)
self._finish_load()
def _internal_load(self, widget):
value = self.property.value
pos = self.input.get_position()
self.input.delete_text(0, -1)
if value:
self.input.insert_text(value)
self.input.set_position(pos)
# validate that the name exists and is unique
if not value:
self.input.set_invalid(self.no_name_msg)
elif self._project.get_gadget_by_name(value) != widget:
self.input.set_invalid(self.duplicate_name_msg)
else:
self.input.set_valid()
def _changed_text(self, entry):
"""
Update the name property of the widget if the name is valid.
"""
if self.property_loading:
return
name = entry.get_chars(0, -1)
if not name:
self.input.set_invalid(self.no_name_msg)
elif self._project.get_gadget_by_name(name):
self.input.set_invalid(self.duplicate_name_msg)
else:
self.input.set_valid()
self.set(name)