My Python program has a GUI written in GTK 3 (I'm using GTK 3 via from gi.repository import Gtk
). I call Gtk.main()
to run the GUI. In addition to running the GUI, the program should constantly monitor standard input for incoming commands and write responses to standard output.
What's the proper way to do this with GTK 3 in Python? Is there some way to hook a stdin listener onto Gtk.main()
? Can I use Python's standard I/O API to read from sys.stdin
and write to sys.stdout
or do I need to use some equivalent Glib API? Can I just write my responses to stdout or do I need to care about buffering and hook my output code to some Glib I/O abstraction?