[Bf-committers] EXPPYTHON sys.executable
Douglas Bischoff
bf-committers@blender.org
Fri, 27 Jun 2003 10:14:36 -0400
Hello:
Sorry this message isn't better targeted, but I'm not sure who can get
this corrected or point me in the right direction.
The command print(sys.executable) on OS X simply returns "/"
This command should return the path to Blender itself since Blender IS
the executable for python programs running within itself.
This is useful mostly for programs that want to spawn another "blender"
such as background renderers.
--- Original Code by Theeth, slight modifications here ---
import os, sys
import Blender
def gui():
Blender.BGL.glClearColor(0.6, 0.6, 0.6, 0.0)
Blender.BGL.glClear(Blender.BGL.GL_COLOR_BUFFER_BIT)
Blender.Draw.Button("ANIM", 1, 10, 10, 80, 20)
Blender.Draw.Button("FRAME", 2, 100, 10, 80, 20)
def event(evt, mode):
if evt == Blender.Draw.ESCKEY: Blender.Draw.Exit()
def bevent(evt):
thefile = "\"" + Blender.Get("filename") + "\""
if evt == 1:
print("Anim render starting of " + thefile)
os.spawnl(os.P_NOWAIT, sys.executable," -b " + thefile, "-a")
if evt == 2:
print("Frame render starting of " + thefile)
os.spawnl(os.P_NOWAIT, sys.executable," -b " + thefile)
Blender.Draw.Register(gui,event,bevent)
---
Note that the implicit quotes appear to be necessary on my system as
without them the space in my volume name breaks the path to the source
file for the render.
-Bish