It does seem to be counter intuitive to block before calling gtk.main(), but
thats the way pygtk has been programmed.  There is an entry in the FAQ about
using threads with pygtk, which explains that you have to surround main with
enter/leave.  I can't remember if it explains why or not.  There was also a
discussion a few days ago on this list about it under the topic of "FAQ Entry
20.6 looks wrong to me."

Jody Steele

Quoting "Marcus Habermehl (BMH1980)" <[EMAIL PROTECTED]>:

> Hi.
>
> Yes, thanks! It seems to work.
>
> But I think it's not very usable to call gtk.gdk.thread_enter() and
> gtk.gdk.thread_leave() before/after mainloop _and_ in the thread block.
>
> That provides mistakes. Like my. ;)
>
> Greetings
> Marcus
>
> [EMAIL PROTECTED] schrieb:
>
> >Hi.  The threads_enter and threads_leave call should go around any calls you
> >make to GTK stuff, not when you create the threads..
> >
> >And it is important to have them surrounding gtk.main() as well..
> >
> >I think what you want is as follows.
> >
> > def get_groups(self, *args):
> >     thread.start_new_thread(self.get_groups_thread, (None, None))
> >
> > def get_groups_thread(self, *args):
> >     gtk.gdk.threads_enter()
> >     for i in my_test.get_groups():
> >         self.liststore1.set(self.liststore1.append(None), 0, i)
> >     gtk.gdk.threads_leave()
> >
> > def run(self):
> >     gtk.gdk.threads_init()
> >     gtk.gdk.threads_enter()
> >     gtk.main()
> >     gtk.gdk.threads_leave()
> >
> >Jody Steele
> >
> >
> >Quoting "Marcus Habermehl (BMH1980)" <[EMAIL PROTECTED]>:
> >
> >> Hi.
> >>
> >> I have a very big problem with threads. Here some lines from my code:
> >>
> >> def get_groups(self, *args):
> >>     gtk.gdk.threads_enter()
> >>     thread.start_new_thread(self.get_groups_thread, (None, None))
> >>     gtk.gdk.threads_leave()
> >>
> >> def get_groups(self, *args):
> >>     for i in my_test.get_groups():
> >>         self.liststore1.set(self.liststore1.append(None), 0, i)
> >>
> >> def run(self):
> >>     gtk.gdk.threads_init()
> >>     gtk.main
> >>
> >> This works. But only a while! :(
> >>
> >> After some time the GUI isn't correct repainted¹. And after this the GUI
> >> is freezing completely.
> >>
> >> I doesn't get any errors. And I think I have understand the FAQ on
> >> http://www.async.com.br/faq/pygtk/ .
> >>
> >> I have try this code, too. But it has the same effect.
> >>
> >> def run(self):
> >>     gtk.gdk.threads_init()
> >>     gtk.gdk.threads_enter()
> >>     gtk.main()
> >>    gtk.gdk.threads_leave()
> >>
> >> Has anyone an idea where the problem is?
> >>
> >> greetings
> >> Marcus
> >>
> >> ¹ = First the scrollbars on the left are missing. After this some lines
> >> in the treeview are missing.
> >>
> >>
> >>
> >>
> >>
> >> ___________________________________________________________
> >> Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier
> anmelden:
> >> http://mail.yahoo.de
> >> _______________________________________________
> >> pygtk mailing list   [email protected]
> >> http://www.daa.com.au/mailman/listinfo/pygtk
> >> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
> >>
> >>
> >
> >
> >
> >
> >----------------------------------------------------------------
> >This message was sent using IMP, the Internet Messaging Program.
> >
> >
> >
>
>
>
>
>
>
> ___________________________________________________________
> Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden:
> http://mail.yahoo.de
> _______________________________________________
> pygtk mailing list   [email protected]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>
>




----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to