Home | Trees | Index | Help |
|
---|
Module Window |
|
This module provides access to Window functions in Blender.
New: many new functions related to screens and events.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")
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 (compare with events from Draw ). |
list with two ints |
Get mouse's current screen coordinates. |
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 |
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. | |
bool |
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 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 | 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)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 (compare with events fromDraw ).
|
GetMouseCoords()Get mouse's current screen coordinates.
|
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(ofs)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 done = 0 while not done: # enter a 'get event' loop evt, val = Window.QRead() # catch next event if 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 and val: # left button pressed v3d = Window.ScreenInfo(Window.Types.VIEW3D) id = v3d[0]['id'] # get the (first) VIEW3D's id Window.QAdd(id, evt, 1) # add the caught mouse event to it # 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.
|
SetViewQuat(quat)Set the current VIEW3D view quaternion.
|
ViewLayer(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 |
---|
QualQualifier keys (shift, control, alt) bitmasks.
|
TypesThe available Window Types.
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Thu Aug 12 21:47:30 2004 | http://epydoc.sf.net |