[solved] running panda with pygtk

Hi everyone.

I am trying to run panda and pygtk in parallel, using thread. I developped the panda part and the pygtk part separatly and I am now trying to run them together, using threads.

I believe that Panda does not run elsewhere than in the main thread, so I left it there. But It seems that pygtk does not love to run in a child thread at all.

I have seen this post discourse.panda3d.org/viewtopic.php … ght=thread but I am not very familiar neither with threads nor with source hacking.

Here is what I try to do :

from browser import *
from Queue import *
from gui import *
import thread

qGuiEvents = Queue()
qWorldEvents = Queue()

thread.start_new_thread(Gui,(qGuiEvents,qWorldEvents))
browser = Browser(qGuiEvents,qWorldEvents)

browser is the panda part, and Gui the gtk part.

When I do this, panda and pygtk are launched, but contrary to pygtk (which runs fine) panda doesn’t work. Windows tells me that the program is not responding etc…

Do you have any idea of how to solve the problem ?

Ok, problem solved.

If someone is interrested, here is the solution :

The main file :

from browser import * # browser is the class managing my Panda3D world
from Queue import *
from gui import * # gui is the pyGtk Gui (see below)
import thread
   
# these Queues are used to speak between pyGtk and Panda3D
qGuiEvents = Queue() 
qWorldEvents = Queue()

thread.start_new_thread(Gui,(qGuiEvents,qWorldEvents))

browser = Browser(qGuiEvents,qWorldEvents)

Gui code :

import pygtk
import gtk
import gtk.glade
import gobject as go


class Gui:
    
    def __init__(self,qGuiEvents,qWorldEvents):
        
        # events queue
        self.qGuiEvents = qGuiEvents # events sent to the GUI
        self.qWorldEvents = qWorldEvents # events sent to the World
        
        # thread-safe :
        gtk.gdk.threads_init()

        # entering main loop
        gtk.gdk.threads_enter()
        gtk.main()
        gtk.gdk.threads_leave()

In fact, it is quite simple, but I had a lot of trouble with that.

And the GUI code needs to go in a file called gui.py, right?

I can’t run your code as I don’t have the browser module that it tries to import. Could you either provide that module or provide a stand-alone demo of GTK integration? Would be very interested.

Thanks

Ok, I just did 3 files to illustrate how it works, but at my job I don’t have access to my ftp account.

How can I send the files to you ?

I could always post the source here, in plain text, but i don’t find it handy. is there a web repository where I could upload the files ? (and where the files will be kept, for this may interrest more people than just chombree)

You should ask pro-rsoft and bigfoot29 for an account on panda3dprojects.com. In the meantime, I will PM you my email address.

Thanks

1 Like

Great Great Great, this open a lot of possibility for editor and so on using Panda and PyGtk…

Dear Mr. Pedro,

Thank you for your good job to running panda with pygtk.

Can you send me 3 files to my email: radvn@robot3t.com

I am very thank you for your help.

Best regards,