36 lines
864 B
Python
36 lines
864 B
Python
#!/usr/bin/env python3
|
|
"""Small GTK tree-selection fixture for the isolated native X11 test."""
|
|
|
|
import gi
|
|
|
|
gi.require_version("Gtk", "3.0")
|
|
from gi.repository import GLib, Gtk
|
|
|
|
|
|
window = Gtk.Window(title="Cthulhu Selection Probe")
|
|
window.connect("destroy", Gtk.main_quit)
|
|
|
|
store = Gtk.ListStore(str)
|
|
store.append(("Alpha result",))
|
|
store.append(("Beta result",))
|
|
|
|
view = Gtk.TreeView(model=store)
|
|
view.set_headers_visible(False)
|
|
view.append_column(Gtk.TreeViewColumn("Result", Gtk.CellRendererText(), text=0))
|
|
view.get_selection().set_mode(Gtk.SelectionMode.SINGLE)
|
|
window.add(view)
|
|
|
|
|
|
def select_result(path):
|
|
view.get_selection().select_path(path)
|
|
view.set_cursor(path)
|
|
return False
|
|
|
|
|
|
window.show_all()
|
|
view.grab_focus()
|
|
GLib.timeout_add(500, select_result, 0)
|
|
GLib.timeout_add(800, select_result, 1)
|
|
GLib.timeout_add(2000, Gtk.main_quit)
|
|
Gtk.main()
|