Blender2.5 pygtk transparent window and pipe/socket example

Blender2.5 can be embedded in Linux using gtk.Socket, see demo:
http://www.youtube.com/watch?v=UjEUQG-1ICs

http://pastebin.com/iPjBpD9P 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
bpy.ops.screen.animation_play('EXEC_DEFAULT')

def draw_callback( area, region ):
	rlist,wlist,xlist = select.select( [sys.stdin], [], [], 0.001 )
	if rlist:
		data = rlist[0].readline()
		print( '>>', len(data) )
		exec( data )
for area in bpy.context.window.screen.areas:
	print(area.type)
	if area.type == 'VIEW_3D':
		area.tag_redraw()
		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')