Open dialog from worker thread
- From: Reg <reg theduke at>
- To: python-hackers-list gnome org
- Subject: Open dialog from worker thread
- Date: Mon, 18 Mar 2013 15:08:42 +0100
Hi there, pyhton hackers.
I have run into an issue with a multi-threaded application using PyGObject.
I have a worker thread that at one point needs to wait for the user to
confirm.
I am doing this with this code:
def showPrompt(self, msg, expectInput=False):
Gdk.threads_enter()
dialog = Gtk.MessageDialog(self.app.mainWindow, 0,
Gtk.MessageType.INFO,
Gtk.ButtonsType.OK, "Backup prompt")
dialog.format_secondary_text(msg)
dialog.run()
dialog.destroy()
Gdk.threads_leave()
It works fine when I call this method from the main thread where
Gtk.main() is run.
When I call it from the worker thread I get weird error messages:
(main.py:17834): Gtk-WARNING **: GtkMessageDialog 0x7fbeb0028020: widget
tried to gtk_widget_get_width inside GtkWidget ::get_width
implementation. Should just invoke
GTK_WIDGET_GET_CLASS(widget)->get_width directly rather than using
gtk_widget_get_width
(main.py:17834): Gtk-WARNING **: GtkBox 0x28f6d50: widget tried to
gtk_widget_get_width inside GtkWidget ::get_width implementation.
Should just invoke GTK_WIDGET_GET_CLASS(widget)->get_width directly
rather than using gtk_widget_get_width
(main.py:17834): Gtk-WARNING **: GtkBox 0x28f6e30: widget tried to
gtk_widget_get_width inside GtkWidget ::get_width implementation.
Should just invoke GTK_WIDGET_GET_CLASS(widget)->get_width directly
rather than using gtk_widget_get_width
(main.py:17834): Gtk-WARNING **: GtkImage 0x2a27dd0: widget tried to
gtk_widget_get_width inside GtkWidget ::get_width implementation.
Should just invoke GTK_WIDGET_GET_CLASS(widget)->get_width directly
rather than using gtk_widget_get_width
/usr/lib/python2.7/site-packages/gi/types.py:47: Warning:
g_hash_table_lookup: assertion `hash_table != NULL' failed
return info.invoke(*args, **kwargs)
(main.py:17834): Gtk-WARNING **: Error loading theme icon
'dialog-information' for stock: Icon 'dialog-information' not present in
theme
Any tipps here?
Note that I am using the global lock with threads_enter/leave.
I'm greatful for any advice,
Christoph Herzog
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]