Module Window
[frames | no frames]

Module Window

The Blender.Window submodule.

Window

This module provides access to Window functions in Blender.

Example:

FileSelector:
 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!")

Example:

DrawProgressBar:
 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
  DrawProgressBar(done, text)
Draw a progress bar in the upper right corner of the screen.
  FileSelector(callback, title)
Open the file selector window in Blender.
list of three floats GetCursorPos()
Get the current 3d cursor position.
4x4 float matrix GetViewMatrix()
Get the current 3d view matrix.
list of three floats GetViewVector()
Get the current 3d view vector.
  ImageSelector(callback, title)
Open the image selector window in Blender.
  QRedrawAll()
Redraw all windows by queue event.
  Redraw()
Force a redraw of a specific Window Type (see Types).
  RedrawAll()
Redraw all windows.
  SetCursorPos(coords)
Change the 3d cursor position.

Variable Summary
readonly dictionary Types: The available Window Types.

Function Details

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.
Parameters:
done - A float in [0.0, 1.0] that tells the advance in the progress bar.
           (type=float)
text - Info about what is currently being done "behind the scenes".
           (type=string)

FileSelector(callback, title='SELECT FILE')

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')
Parameters:
callback - The function that must be provided to FileSelector() and will receive the selected filename as parameter.
           (type=function that accepts a string: f(str))
title - The string that appears in the button to confirm the selection and return from the file selection window.
           (type=string)

GetCursorPos()

Get the current 3d cursor position.
Returns:
the current position: [x, y, z].
           (type=list of three floats)

GetViewMatrix()

Get the current 3d view matrix.
Returns:
the current matrix.
           (type=4x4 float matrix)

GetViewVector()

Get the current 3d view vector.
Returns:
the current vector: [x, y, z].
           (type=list of three floats)

ImageSelector(callback, title='SELECT IMAGE')

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')
Parameters:
callback - The function that must be provided to ImageSelector() and will receive the selected filename as parameter.
           (type=function that accepts a string: f(str))
title - The string that appears in the button to confirm the selection and return from the image selection window.
           (type=string)

QRedrawAll()

Redraw all windows by queue event.

Redraw()

Force a redraw of a specific Window Type (see Types).

RedrawAll()

Redraw all windows.

SetCursorPos(coords)

Change the 3d cursor position. Note: if visible, the 3d window must be redrawn to display the change. This can be done with Redraw(Types['VIEW3D']), for example.
Parameters:
coords - The new x, y, z coordinates.
           (type=3 floats or a list of 3 floats)

Variable Details

Types

The available Window Types.
  • VIEW3D
  • IPO
  • OOPS
  • BUTS
  • FILE
  • IMAGE
  • INFO
  • SEQ
  • IMASEL
  • SOUND
  • ACTION
  • TEXT
  • NLA
Type:
readonly dictionary

Generated by Epydoc 2.0 on Sat Nov 29 19:05:58 2003 http://epydoc.sf.net