Re: python-hackers-list Digest, Vol 21, Issue 2



Hi Jérôme,

2012/1/17 Jérôme <jerome jolimont fr>:
>
> I might sound silly, but you wrote "after main", so I'm in doubt.
>
> Here's how I do it in my GTK application :
>
> if __name__ == "__main__":
>    GObject.threads_init()
>    my_stuff()
>    Gtk.main()

I do it rather similarly but as I am building a pure GLib app from
GObject-based library, I don't have any Gtk dependencies and therefore
the Gtk main loop is not helping. I will just sketch, how it is done
now (Foo is the GObject-based library written in C):

from gi.repository import Foo, GObject

class MyFilter(Foo.Filter):
    def do_process(self, data):
        print data

if __name__ == '__main__':
    GObject.threads_init()
    f = MyFilter()
    caller = Foo.Caller()
    caller.call(f, None)

foo_caller_call() basically creates a thread that calls the
foo_filter_process() method of the passed object and joins this
thread. If I don't create a thread but just call foo_filter_process()
from foo_caller_call() everything works fine and the Python code is
executed.

Regards.

-- 
Matthias Vogelgesang
Public-Key: http://tinyurl.com/2qcydl


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]