|__init__(iohub_display[, res, color, ...])|
|callOnFlip(function, *args, **kwargs)||Call a function immediately after the next .flip() command.|
|clearBuffer()||Clear the back buffer (to which you are currently drawing) without flipping the window.|
|close()||Close the window (and reset the Bits++ if necess).|
|fps()||Report the frames per second since the last call to this function|
|getMovieFrame([buffer])||Capture the current Window as an image.|
|logOnFlip(msg, level[, obj])||Send a log message that should be time-stamped at the next .flip() command.|
|multiFlip([flips, clearBuffer])||Flips multiple times while maintaining display constant.|
|onResize(width, height)||A default resize event handler.|
|saveFrameIntervals([fileName, clear])||Save recorded screen frame intervals to disk, as comma-separated values.|
|saveMovieFrames(fileName[, mpgCodec, fps, ...])||Writes any captured frames to disk.|
|setBuffer(buffer[, clear])||Choose which buffer to draw to (‘left’ or ‘right’).|
|setColor(color[, colorSpace, operation])||Set the color of the window.|
|setGamma(gamma)||Set the monitor gamma, using Bits++ if possible|
|setMouseVisible(visibility)||Sets the visibility of the mouse cursor.|
|setRGB(newRGB)||Deprecated: As of v1.61.00 please use setColor() instead|
|setRecordFrameIntervals([value])||To provide accurate measures of frame intervals, to determine whether frames are being dropped.|
|setScale(units[, font, prevScale])||This method is called from within the draw routine and sets the|
|update()||Deprecated: use Window.flip() instead|
Call a function immediately after the next .flip() command.
The first argument should be the function to call, the following args should be used exactly as you would for your normal call to the function (can use ordered arguments or keyword arguments as normal).
e.g. If you have a function that you would normally call like this:
pingMyDevice(portToPing, channel=2, level=0)
then you could call callOnFlip() to have the function call synchronized with the frame flip like this:
win.callOnFlip(pingMyDevice, portToPing, channel=2, level=0)
Clear the back buffer (to which you are currently drawing) without flipping the window. Useful if you want to generate movie sequences from the back buffer without actually taking the time to flip the window.
Close the window (and reset the Bits++ if necess).
Report the frames per second since the last call to this function (or since the window was created if this is first call)
Capture the current Window as an image. This can be done at any time (usually after a .update() command).
Frames are stored in memory until a .saveMovieFrames(filename) command is issued. You can issue getMovieFrame() as often as you like and then save them all in one go when finished.
Send a log message that should be time-stamped at the next .flip() command.
Flips multiple times while maintaining display constant. Use this method for precise timing.
flips: number of monitor frames to flip image. Window.multiFlip(flips=1) is equivalent to Window.flip().
clearBuffer: as in Window.flip(). This is applied to the last flip.
myStim1.draw() # Draws myStim1 to buffer myWin.multiFlip(clearBuffer=False, flips=6) # Show stimulus for 4 frames (90 ms at 60Hz) myStim2.draw() # Draw myStim2 "on top of" myStim1 (because buffer was not cleared above) myWin.multiFlip(flips=2) # Show this for 2 frames (30 ms at 60Hz) myWin.multiFlip(flips=3) # Show blank screen for 3 frames (because buffer was cleared above)
A default resize event handler.
This default handler updates the GL viewport to cover the entire window and sets the GL_PROJECTION matrix to be orthagonal in window space. The bottom-left corner is (0, 0) and the top-right corner is the width and height of the Window in pixels.
Override this event handler with your own to create another projection, for example in perspective.
Save recorded screen frame intervals to disk, as comma-separated values.
Writes any captured frames to disk. Will write any format that is understood by PIL (tif, jpg, bmp, png...)
mpgCodec: the code to be used by pymedia if the filename ends in .mpg
fps: the frame rate to be used throughout the movie only for quicktime (.mov) movies
myWin.saveMovieFrames('frame.tif')#writes a series of static frames as frame001.tif, frame002.tif etc... myWin.saveMovieFrames('stimuli.mov', fps=25)#on OS X only myWin.saveMovieFrames('stimuli.gif')#not great quality animated gif myWin.saveMovieFrames('stimuli.mpg')#not on OS X
Choose which buffer to draw to (‘left’ or ‘right’).
Requires the Window to be initialised with stereo=True and requires a graphics card that supports quad buffering (e,g nVidia Quadro series)
PsychoPy always draws to the back buffers, so ‘left’ will use GL_BACK_LEFT This then needs to be flipped once both eye’s buffers have been rendered.
win = visual.Window(...., stereo=True) while True: win.setBuffer('left',clear=True) #clear may not actually be needed #do drawing for left eye win.setBuffer('right', clear=True) #do drawing for right eye win.flip()
Set the color of the window.
NB This command sets the color that the blank screen will have on the next clear operation. As a result it effectively takes TWO flip() operations to become visible (the first uses the color to create the new screen, the second presents that screen to the viewer).
See colorspaces for further information about the ways to specify colors and their various implications.
Can be specified in one of many ways. If a string is given then it is interpreted as the name of the color. Any of the standard html/X11 color names <http://www.w3schools.com/html/html_colornames.asp> can be used. e.g.:
myStim.setColor('white') myStim.setColor('RoyalBlue')#(the case is actually ignored)
A hex value can be provided, also formatted as with web colors. This can be provided as a string that begins with # (not using python’s usual 0x000000 format):
myStim.setColor('#DDA0DD')#DDA0DD is hexadecimal for plum
You can also provide a triplet of values, which refer to the coordinates in one of the colorspaces. If no color space is specified then the color space most recently used for this stimulus is used again.
myStim.setColor([1.0,-1.0,-1.0], ‘rgb’)#a red color in rgb space myStim.setColor([0.0,45.0,1.0], ‘dkl’) #DKL space with elev=0, azimuth=45 myStim.setColor([0,0,255], ‘rgb255’) #a blue stimulus using rgb255 space
Lastly, a single number can be provided, x, which is equivalent to providing [x,x,x].
myStim.setColor(255, ‘rgb255’) #all guns o max
colorSpace : string or None
defining which of the colorspaces to use. For strings and hex values this is not needed. If None the default colorSpace for the stimulus is used (defined during initialisation).
operation : one of ‘+’,’-‘,’*’,’/’, or ‘’ for no operation (simply replace value)
for colors specified as a triplet of values (or single intensity value) the new value will perform this operation on the previous colorthisStim.setColor([1,1,1],’rgb255’,’+’)#increment all guns by 1 value thisStim.setColor(-1, ‘rgb’, ‘*’) #multiply the color by -1 (which in this space inverts the contrast) thisStim.setColor([10,0,0], ‘dkl’, ‘+’)#raise the elevation from the isoluminant plane by 10 deg
Set the monitor gamma, using Bits++ if possible
Sets the visibility of the mouse cursor.
If Window was initilised with noGUI=True then the mouse is initially set to invisible, otherwise it will initially be visible.
Deprecated: As of v1.61.00 please use setColor() instead
To provide accurate measures of frame intervals, to determine whether frames are being dropped. The intervals are the times between calls to .flip(). Set to True only during the time-critical parts of the script. Set this to False while the screen is not being updated, i.e., during any slow, non-frame-time-critical sections of your code, including inter-trial-intervals, event.waitkeys(), core.wait(), or image.setImage().
This method is called from within the draw routine and sets the scale of the OpenGL context to map between units. Could potentially be called by the user in order to draw OpenGl objects manually in each frame.
The units can be ‘height’ (multiples of window height), ‘norm’(normalised), ‘pix’(pixels), ‘cm’ or ‘stroke_font’. The font parameter is only used if units=’stroke_font’
Deprecated: use Window.flip() instead