本文整理汇总了Python中efl.elementary.entry.Entry.callback_cursor_changed_add方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.callback_cursor_changed_add方法的具体用法?Python Entry.callback_cursor_changed_add怎么用?Python Entry.callback_cursor_changed_add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类efl.elementary.entry.Entry
的用法示例。
在下文中一共展示了Entry.callback_cursor_changed_add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Interface
# 需要导入模块: from efl.elementary.entry import Entry [as 别名]
# 或者: from efl.elementary.entry.Entry import callback_cursor_changed_add [as 别名]
#.........这里部分代码省略.........
# and the GUI on the other
self.flip = Flip(self.mainWindow, size_hint_weight=EXPAND_BOTH,
size_hint_align=FILL_BOTH)
self.flip.part_content_set("front", self.mainBox)
self.flip.part_content_set("back", self.fileBox)
self.mainWindow.resize_object_add(self.flip)
self.flip.show()
self.isSaved = True
self.isNewFile = False
self.confirmPopup = None
self.fileExistsFlag = False
def entryInit(self):
self.mainEn = Entry(self.mainWindow, scrollable=True,
line_wrap=self.wordwrap, autosave=False,
size_hint_weight=EXPAND_BOTH,
size_hint_align=FILL_BOTH)
self.mainEn.callback_changed_user_add(self.textEdited)
self.mainEn.elm_event_callback_add(self.eventsCb)
self.mainEn.callback_clicked_add(resetCloseMenuCount)
# delete line lable if it exist so we can create and add new one
# Later need to rethink logic here
try:
self.line_label.delete()
except AttributeError:
pass
# Add label to show current cursor position
if SHOW_POS:
self.line_label = Label(self.mainWindow,
size_hint_weight=EXPAND_HORIZ,
size_hint_align=ALIGN_RIGHT)
self.mainEn.callback_cursor_changed_add(self.curChanged,
self.line_label)
self.curChanged(self.mainEn, self.line_label)
self.line_label.show()
self.mainBox.pack_end(self.line_label)
# self.mainEn.markup_filter_append(self.textFilter)
self.mainEn.show()
self.mainEn.focus_set(True)
try:
self.mainBox.pack_before(self.mainEn, self.line_label)
except AttributeError:
# line_label has not been initialized on first run
# Should have better logic on all this
self.mainBox.pack_end(self.mainEn)
def curChanged(self, entry, label):
# get linear index into current text
index = entry.cursor_pos_get()
# Replace <br /> tag with single char
# to simplify (line, col) calculation
tmp_text = markup_to_utf8(entry.entry_get())
line = tmp_text[:index].count("\n") + 1
col = len(tmp_text[:index].split("\n")[-1]) + 1
# Update label text with line, col
label.text = "Ln {0} Col {1} ".format(line, col)
def textEdited(self, obj):
current_file = self.mainEn.file[0]
current_file = \
os.path.basename(current_file) if \
current_file and not self.isNewFile else \
"Untitled"