0

I CReated a GtkNotebook from which pages(using Gtk.Builder.new_from_file(file_path)) are added dynamically from a python thread but the code failed with

(erticket.py:16928): Gtk-CRITICAL **: gtk_text_attributes_ref: assertion 'values != NULL' failed

(erticket.py:16928): Gtk-CRITICAL **: gtk_text_attributes_ref: assertion 'values != NULL' failed

(erticket.py:16928): Pango-CRITICAL **: pango_layout_new: assertion 'context != NULL' failed Segmentation fault (core dumped)

I want to know if it is possible to instanciate a GtkWidget from a Python thread because something seems not clear I think it can be but I'm not sure. I don't understand why a segmentation fault occurs here. Very very strange....

  • 2
    If a Python thread maps to an OS thread then no, GTK+ is not thread safe and all GTK+ operations, including GtkBuilder, must be done from a single thread. – andlabs Jul 30 '15 at 22:12
  • could you give me more details about that? some example or tuto? thanks also, can you suggest me a solution for this? – Narcisse Doudieu Siewe Jul 30 '15 at 22:43
  • 1
    The solution is to do all GTK operations from the main thread. If you need a worker thread for long-running computations, you can send messages to the main thread when you need to update the UI, but you can't update the UI from the worker thread; see diagram [here](http://stackoverflow.com/a/30610923/172999) for an example. – ptomato Aug 01 '15 at 17:22

0 Answers0