Home | Trees | Indices | Help |
|
---|
|
The Blender.Window submodule.
New: renamed ViewLayer to ViewLayers (actually added an alias, so both forms will work).import Blender from Blender import Window # def my_callback(filename): # callback for the FileSelector print "You chose the file:", filename # do something with the chosen file # Window.FileSelector (my_callback, "Choose one!")
import Blender from Blender.Window import DrawProgressBar # # substitute the bogus_*() function calls for your own, of course. # DrawProgressBar (0.0, "Importing data ...") bogus_importData() DrawProgressBar (0.3, "Building something") bogus_build() DrawProgressBar (0.8, "Updating Blender") bogus_update() DrawProgressBar (1.0, "Finished") # # another example: # number = 1 while number < 20: file = filename + "00%d" % number DrawProgressBar (number / 20.0, "Loading texture: %s" % file) Blender.Image.Load(file) number += 1 DrawProgressBar (1.0, "Finished loading")
Warning: The event system in Blender needs a rewrite, though we don't know when that will happen. Until then, event related functions here (QAdd, QRead, QHandle, etc.) can be used, but they are actually experimental and can be substituted for a better method when the rewrite happens. In other words, use them at your own risk, because though they should work well and allow many interesting and powerful possibilities, they can be deprecated in some future version of Blender / Blender Python.
Functions | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
list of three floats |
|
||
int |
|
||
|
|||
|
|||
int |
|
||
|
|||
|
|||
list of three floats |
|
||
4x4 float matrix (WRAPPED DATA) |
|
||
4x4 float matrix (WRAPPED DATA) |
|
||
int (bool) |
|
||
|
|||
list of ints |
|
||
list of floats |
|
||
|
|||
list of floats |
|
||
|
|||
|
|||
int |
|
||
list |
|
||
|
|||
|
|||
bool |
|
||
list with two ints |
|
||
|
|||
int |
|
||
int |
|
||
int |
|
||
|
|||
list with two ints |
|
||
list with two ints |
|
||
list of strings |
|
||
|
|||
list of dictionaries |
|
Variables | |
readonly dictionary |
MButs Mouse buttons. |
readonly dictionary |
Qual Qualifier keys (shift, control, alt) bitmasks. |
readonly dictionary |
Types The available Window Types. |
Function Details |
|
import Blender # def my_function(filename): print 'The selected file was:', filename # Blender.Window.FileSelector (my_function, 'SAVE FILE')
Warning: script links are not allowed to call the File / Image Selectors. This is because script links global dictionaries are removed when they finish execution and the File Selector needs the passed callback to stay around. An alternative is calling the File Selector from another script (see Blender.Run). |
import Blender # def my_function(imagename): print 'The selected image was:', imagename # Blender.Window.ImageSelector (my_function, 'LOAD IMAGE')
Warning: script links are not allowed to call the File / Image Selectors. This is because script links global dictionaries are removed when they finish execution and the File Selector needs the passed callback to stay around. An alternative is calling the File Selector from another script (see Blender.Run). |
|
|
Note: if there is no 3d view it will return zero. |
|
Note: if visible, the 3d View must be redrawn to display the change. This can be done with Redraw. |
|
|
Set cursor to wait or back to normal mode. Example:Blender.Window.WaitCursor(1) Blender.sys.sleep(2000) # do something that takes some time Blender.Window.WaitCursor(0) # back
Note: when the script finishes execution, the cursor is set to normal by Blender itself. |
|
|
|
Get and optionally set the current edit mode status: in or out. Example:in_editmode = Window.EditMode() # MUST leave edit mode before changing an active mesh: if in_editmode: Window.EditMode(0) # ... # make changes to the mesh # ... # be nice to the user and return things to how they were: if in_editmode: Window.EditMode(1)
Warning: this is an important function. NMesh operates on normal Blender meshes, not edit mode ones. If a script changes an active mesh while in edit mode, when the user leaves the mode the changes will be lost, because the normal mesh will be rebuilt based on its unchanged edit mesh. |
Warning: This uses the active armature objects posemode status, enabling pose mode for non armature objects will always fail. |
|
|
|
Note: The 3 values returned are flipped in comparison object locations. |
Note: The value you give flipped in comparison object locations. |
|
|
Get the next pending event from the event queue. Example:# let's catch all events and move the 3D Cursor when user presses # the left mouse button. from Blender import Draw, Window v3d = Window.GetScreenInfo(Window.Types.VIEW3D) id = v3d[0]['id'] # get the (first) VIEW3D's id done = 0 while not done: # enter a 'get event' loop evt, val = Window.QRead() # catch next event if evt in [Draw.MOUSEX, Draw.MOUSEY]: continue # speeds things up, ignores mouse movement elif evt in [Draw.ESCKEY, Draw.QKEY]: done = 1 # end loop elif evt == Draw.SPACEKEY: Draw.PupMenu("Hey!|What did you expect?") elif evt == Draw.Redraw: # catch redraw events to handle them Window.RedrawAll() # redraw all areas elif evt == Draw.LEFTMOUSE: # left button pressed Window.QAdd(id, evt, 1) # add the caught mouse event to our v3d # actually we should check if the event happened inside that area, # using Window.GetMouseCoords() and v3d[0]['vertices'] values. Window.QHandle(id) # process the event # do something fancy like putting some object where the # user positioned the 3d cursor, then: Window.Redraw() # show the change in the VIEW3D areas.
|
|
Note: see QAdd for how to send events to a particular window. |
|
|
|
|
|
Warning: remember to reset the qual keys to 0 once they are not necessary anymore. |
Note: the returned values are 1 pixel bigger than what GetScreenInfo returns for the 'vertices' of the same area. |
|
|
|
|
Variables Details |
MButsMouse buttons.
|
QualQualifier keys (shift, control, alt) bitmasks.
|
TypesThe available Window Types.
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Mon May 19 15:32:20 2008 | http://epydoc.sourceforge.net |