Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- '''
- Embeding Blender in a PyGTK Window Demo
- Goathead - July 20, 2010
- Useage: (linux only)
- 1. Run this script "python embedblender-demo.py"
- 2. Blender will popup in a small window, you must click it within 5 seconds
- 3. The Blender window is moved to the GTK window,
- you should be able to continue to interact with Blender
- Known Issues:
- 1. Losing window focus can disable mouse click input,
- mouse wheel and keyboard seem to always work
- 2. Not clicking the Blender window when it first appears can cause it to not be
- responsive when its embeded in the pygtk window.
- '''
- # change this path to your blender25 folder #
- PATH2BLENDER = 'Desktop/blender25'
- ''' Blender25 has a bug if you had "saved as default" your own startup blend
- --window-geometry fails to be respected and blender opens a full screen window,
- uncomment the line below to remove your startup blend so this demo can work properly. '''
- #os.system('mv $HOME/.blender/2.52/config/startup.blend $HOME/mystartup.blend')
- ## end user options ##
- import os, sys, time
- import gtk
- BWIDTH=640; BHEIGHT=480
- os.system('killall blender')
- os.system('%s/blender --window-geometry 10 10 %s %s &' %(PATH2BLENDER,BWIDTH,BHEIGHT))
- win = gtk.Window()
- win.connect('destroy', lambda w: gtk.main_quit())
- #win.set_size_request( 800, 500 )
- frame = gtk.Frame('embeding blender in gtk demo')
- frame.set_border_width( 20 )
- win.add(frame)
- soc = gtk.Socket()
- soc.set_border_width(10)
- frame.add( soc )
- time.sleep(5)
- p =os.popen('xwininfo -int -name Blender')
- data = p.read().strip().splitlines()
- p.close()
- print( data )
- wid = long( data[0].split()[3] )
- print( 'embeding blender', wid )
- soc.add_id( wid )
- pw = soc.get_plug_window()
- #BWIDTH,BHEIGHT = pw.get_size()
- soc.set_size_request( BWIDTH, BHEIGHT )
- win.show_all()
- gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement