Home | Trees | Index | Help |
|
---|
Module Window |
|
The Blender.Window submodule.
New: renamed ViewLayer toViewLayers
(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.
Function Summary | |
---|---|
Set the current VIEW3D view to the active camera's view. | |
Draw a progress bar in the upper right corner of the screen. | |
int (bool) |
Get and optionally set the current edit mode status: in or out. |
Open the file selector window in Blender. | |
Get the current area's ID. | |
list with two ints |
Get the current area's size. |
list of three floats |
Get the current 3d cursor position. |
int |
Get the current qualifier keys state (see / compare against Qual ). |
int |
Get the current mouse button state (see / compare against MButs ). |
list with two ints |
Get mouse's current screen coordinates. |
4x4 float matrix (WRAPPED DATA) |
Get the current 3d perspective matrix. |
list of dictionaries |
Get info about the current screen setup. |
list of strings |
Get the names of all available screens. |
list with two ints |
Get Blender's screen size. |
4x4 float matrix (WRAPPED DATA) |
Get the current 3d view matrix. |
list of floats |
Get the current VIEW3D offset values. |
list of floats |
Get the current VIEW3D view quaternion values. |
list of three floats |
Get the current 3d view vector. |
Open the image selector window in Blender. | |
Add an event to some window's (actually called areas in Blender) event queue. | |
Process immediately all pending events for the given window (area). | |
list |
Get the next pending event from the event queue. |
Redraw all windows by queue event. | |
int |
Check if there are pending events in the event queue. |
Force a redraw of a specific space type. | |
Redraw all windows. | |
Change the 3d cursor position. | |
int |
Fake qualifier keys state. |
Set mouse's current screen coordinates. | |
Set as current screen the one with the given name. | |
Set the current VIEW3D offset values. | |
Set the current VIEW3D view quaternion. | |
list of ints |
Get and optionally set the currently visible layers in all 3d Views. |
Set cursor to wait or back to normal mode. |
Variable Summary | |
---|---|
readonly dictionary | MButs : Mouse buttons. |
readonly dictionary | Qual : Qualifier keys (shift, control, alt) bitmasks. |
readonly dictionary | Types : The available Window Types. |
Function Details |
---|
CameraView(camtov3d=0)Set the current VIEW3D view to the active camera's view. If there's no active object or it is not of type 'Camera', the active camera for the current scene is used instead.
|
DrawProgressBar(done, text)Draw a progress bar in the upper right corner of the screen. To cancel it prematurely, users can press the "Esc" key. Start it with done = 0 and end it with done = 1.
|
EditMode(enable=-1, undo_msg='From script', undo=1)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)
|
FileSelector(callback, title='SELECT FILE', filename='<default>')Open the file selector window in Blender. After the user selects a filename, it is passed as parameter to the function callback given to FileSelector(). Example:import Blender # def my_function(filename): print 'The selected file was:', filename # Blender.Window.FileSelector (my_function, 'SAVE FILE')
|
GetAreaID()Get the current area's ID. |
GetAreaSize()Get the current area's size.
|
GetCursorPos()Get the current 3d cursor position.
|
GetKeyQualifiers()Get the current qualifier keys state (see / compare againstQual ).
|
GetMouseButtons()Get the current mouse button state (see / compare againstMButs ).
|
GetMouseCoords()Get mouse's current screen coordinates.
|
GetPerspMatrix()Get the current 3d perspective matrix.
|
GetScreenInfo(type=-1, rect='win', screen='')Get info about the current screen setup.
|
GetScreens()Get the names of all available screens.
|
GetScreenSize()Get Blender's screen size.
|
GetViewMatrix()Get the current 3d view matrix.
|
GetViewOffset()Get the current VIEW3D offset values.
|
GetViewQuat()Get the current VIEW3D view quaternion values.
|
GetViewVector()Get the current 3d view vector.
|
ImageSelector(callback, title='SELECT IMAGE', filename='<default>')Open the image selector window in Blender. After the user selects a filename, it is passed as parameter to the function callback given to ImageSelector(). Example:import Blender # def my_function(imagename): print 'The selected image was:', imagename # Blender.Window.ImageSelector (my_function, 'LOAD IMAGE')
|
QAdd(win, event, val, after=0)Add an event to some window's (actually called areas in Blender) event queue.
|
QHandle(winId)Process immediately all pending events for the given window (area).
|
QRead()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.
|
QRedrawAll()Redraw all windows by queue event. |
QTest()Check if there are pending events in the event queue.
|
Redraw(spacetype='<Types.VIEW3D>')Force a redraw of a specific space type.
|
RedrawAll()Redraw all windows. |
SetCursorPos(coords)Change the 3d cursor position.
|
SetKeyQualifiers(qual)Fake qualifier keys state. This is useful because some key events require one or more qualifiers to be active (seeQAdd ).
|
SetMouseCoords(coords)Set mouse's current screen coordinates.
|
SetScreen(name)Set as current screen the one with the given name.
|
SetViewOffset(ofs)Set the current VIEW3D offset values.
|
SetViewQuat(quat)Set the current VIEW3D view quaternion.
|
ViewLayers(layers=[])Get and optionally set the currently visible layers in all 3d Views.
|
WaitCursor(bool)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
|
Variable Details |
---|
MButsMouse buttons.
|
QualQualifier keys (shift, control, alt) bitmasks.
|
TypesThe available Window Types.
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Thu Jul 13 16:50:06 2006 | http://epydoc.sf.net |