Blender2.5 pygtk transparent window and pipe/socket example

Blender2.5 can be embedded in Linux using gtk.Socket, see demo: module for talking to blender over a pipe, also works with a socket connection.

Getting Blender2.5 to listen on a pipe or socket is not easy, this hack can be used if run from the command line as a python script. It forces blender into playback mode and listens on the pipe in draw_callback.

import os,sys, bpy, select

def draw_callback( area, region ):
	rlist,wlist,xlist = [sys.stdin], [], [], 0.001 )
	if rlist:
		data = rlist[0].readline()
		print( '>>', len(data) )
		exec( data )
for area in bpy.context.window.screen.areas:
	if area.type == 'VIEW_3D':
		for reg in area.regions:
			print( '	region: ', reg.type )
			if reg.type == 'WINDOW':
				print( 'adding callback' )
				reg.callback_add(draw_callback, (area,reg), 'POST_PIXEL')