32 lines
709 B
Python
32 lines
709 B
Python
#!/usr/bin/env python3
|
|
"""Multiline editor with existing text on both sides of the insertion point."""
|
|
import sys
|
|
|
|
import gi
|
|
|
|
gi.require_version("Gtk", "3.0")
|
|
from gi.repository import GLib, Gtk
|
|
|
|
|
|
window = Gtk.Window(title="Typing echo probe")
|
|
window.set_default_size(480, 200)
|
|
window.connect("destroy", Gtk.main_quit)
|
|
editor = Gtk.TextView()
|
|
editor.set_accepts_tab(False)
|
|
editor.get_accessible().set_name("Echo editor")
|
|
buffer = editor.get_buffer()
|
|
buffer.set_text("Hello following text")
|
|
buffer.place_cursor(buffer.get_iter_at_offset(int(sys.argv[1])))
|
|
window.add(editor)
|
|
window.show_all()
|
|
editor.grab_focus()
|
|
|
|
|
|
def ready():
|
|
print("READY", flush=True)
|
|
return False
|
|
|
|
|
|
GLib.idle_add(ready)
|
|
Gtk.main()
|