How can I update a Gtk.TextView from events from a different thread?
<p>In a separate thread, I check for information in the pySerial Buffer (Infinite Loop). If new information is available, I'd like to show that Input in a <code>Gtk.TextView</code>. After Googling on the subject it turns out doing Gtk -Stuff inside threads is a killer. Random errors will appear and so on, which was also a problem I ran into.</p>

<p>I decided to use a queue to synchronize the thread with the GUI. Putting information into a queue is pretty simple, but how do I suppose to check in the mainloop if there are any entries in the queue? </p>

<p>Some kind of event would be nice, which triggers if any new information is available.</p>

<p>Is there anything of that kind? Maybe a function exists to implement custom python code into the GTK3+ mainloop?</p>

<p>Found a Solution:</p>

<blockquote>
  <p>GObject.timeout_add</p>
</blockquote>

<p><a href="http://www.pygtk.org/pygtk2reference/gobject-functions.html#function-gobject--timeout-add" rel="nofollow">http://www.pygtk.org/pygtk2reference/gobject-functions.html#function-gobject--timeout-add</a></p>

<p>This GObject Function implements a Callback to a own Function every X Milliseconds. Found a pritty simple Explanation here:</p>

<p><a href="https://gist.github.com/jampola/473e963cff3d4ae96707" rel="nofollow">https://gist.github.com/jampola/473e963cff3d4ae96707</a></p>

<p>So i can work down all Informations gathered from the Queue every X Milliseconds. Nice way for dealing with Threads! </p>

python user-interface queue gtk3 python-multithreading