April 2018
Beginner
340 pages
7h 54m
English
Open back up the demo file we created earlier, which shows off the current cursor location. Underneath your update_index function, we will add four more bindings which will be used to practice the utilization of these special strings:
def down_three_lines(event=None): current_cursor_index = str(text.index(tk.INSERT)) new_position = current_cursor_index + "+3l" text.mark_set(tk.INSERT, new_position) return "break"def back_four_chars(event=None): current_cursor_index = str(text.index(tk.INSERT)) new_position = current_cursor_index + "-4c" text.mark_set(tk.INSERT, new_position) return "break"
These two functions demonstrate the use of the +nl and -nc strings.
We get the cursor's current position in the same way as before, ...