[pygtk] seperate thread for database query

Chris Lambacher lambacck at gmail.com
Thu Oct 14 22:26:34 WST 2004

You should be able to do it, but you will need to purposely release
the gui by calling gtk.threads_leave()
#sleep here

In your loop to allow the gtk mainloop to do what it needs to do with
the display.  This will make the update even slower though.  You need
to make a decision about what is more important, responsiveness of
your interface, or filling the list.  If filling the list is integral
to your interface, then perhapse it is ok to make the user wait. 
Maybe you want to pop up a dialog with a progress indicator or
something like that.

You could also make your insert faster by not having your treemodel
connected to your treeview, then the display would not have to be
update on every insert(less signal handlers going).

On Thu, 14 Oct 2004 16:09:29 +0159, Matthias Teege <mteege at gmail.com> wrote:
> On Thu, 14 Oct 2004 08:44:29 -0400, Chris Lambacher <lambacck at gmail.com> wrote:
> > The threads_init, threads_enter and threads_leave calls on provide
> > mutual exclusion on the gtk interface.  You can only be accessing the
> > display from one thread at a time.  You will have to use the normal
> Does this mean, that It isn't possible to start the interface in a
> mode where I can work with it and fill long lists secondary? The
> problem isn't the database query which is very fast but looping to the
> result and insert the items to the treemodel is slow. What I really
> need is a asynchronous treemodel.
> Matthias

Christopher Lambacher
lambacck at computer.org

More information about the pygtk mailing list