Captura de janela GTK: aplicativo VPython (OpenGL)

Depois de ler a documentação paraVPython eEncadeamento GTK, parece-me que seria possível incorporar gráficos VPython dentro de uma GUI gtk. Eu sei que isso é possível comwx no Windows mas estou no Linux e usando o PyGTK. Agora, consegui fazer parte do caminho. Posso incorporar uma janela do VPythondesde que seja gerado um processo separado. O que eu gostaria é de incorporá-lo como um segmento. O último tornaria os eventos GUI que controlam o OpenGL mais fáceis de implementar - por meio de um thread em vez de um soquete e chamadas de rede.

Edit: Aparentemente, ninguém sabe nada sobre isso ... Meh.

Aqui está o código que tenho. Uncomment as duas linhas comentadas e comentar alguns outros óbvios e você pode obter o código de desova do processo.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
from visual import *
import threading
import Queue
import gtk
import pygtk
import re
import subprocess


class OPenGLThreadClass (threading.Thread):
    """Thread running the VPython code."""

    def __init__(self, queue):
        threading.Thread.__init__(self)
        self.queue = queue
        self.name = 'OpenGLThread'


    def run (self):
        gtk.threads_enter()
        self.scene = display.get_selected() 
        self.scene.title = 'OpenGL test'
        s = sphere()
        gtk.threads_leave()
        #P = subprocess.Popen(['python', 'opengl.py'])
        time.sleep(2)
        self.queue.put(self.find_window_id())
        self.queue.task_done()


    def find_window_id (self):
        """Gets the OpenGL window ID."""
        pattern = re.compile('0x[0-9abcdef]{7}')
        P = subprocess.Popen(['xwininfo', '-name', self.scene.title],
        #P = subprocess.Popen(['xwininfo', '-name', 'Visual WeldHead'],
                stdout=subprocess.PIPE)
        for line in P.stdout.readlines():
            match = pattern.findall(line)
            if len(match):
                ret = long(match[0], 16)
                print("OpenGL window id is %d (%s)" % (ret, hex(ret)))
                return ret


class GTKWindowThreadClass (threading.Thread):
    """Thread running the GTK code."""

    def __init__ (self, winID):
        threading.Thread.__init__(self)
        self.OpenGLWindowID = winID
        self.name = 'GTKThread'


    def run (self):
        """Draw the GTK GUI."""
        gtk.threads_enter()
        window = gtk.Window()
        window.show()
        socket = gtk.Socket()
        socket.show()
        window.add(socket)
        window.connect("destroy", lambda w: gtk.main_quit())
        print("Got winID as %d (%s)" % (self.OpenGLWindowID, hex(self.OpenGLWindowID)))
        socket.add_id(long(self.OpenGLWindowID))
        gtk.main()
        gtk.threads_leave()



def main ():
    thread = {}
    print("Embedding OpenGL/VPython into GTK GUI")
    queue = Queue.Queue()
    thread['OpenGL'] = OPenGLThreadClass(queue)
    thread['OpenGL'].start()
    winID = queue.get()
    print("Got winID as %d (%s)" % (winID, hex(winID)))
    gtk.gdk.threads_init()
    thread['GTK'] = GTKWindowThreadClass(winID)
    thread['GTK'].start()



if __name__ == "__main__":
    main()

questionAnswers(1)

yourAnswerToTheQuestion