textStimuli_pygame.py :  » Game-2D-3D » PsychoPy » PsychoPy-0.96.02 » psychopy » demos » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Game 2D 3D » PsychoPy 
PsychoPy » PsychoPy 0.96.02 » psychopy » demos » textStimuli_pygame.py
#! /usr/local/bin/python2.5
from psychopy import *
import sys

#create a window to draw in
myWin = visual.Window((600.0,600.0),allowGUI=False,
        monitor='testMonitor', units ='cm', winType='pygame')
    
if sys.platform=='win32':
    fancy = 'c:\\windows\\fonts\\brush' #this will find brush script
    sans = 'arial' #on windows you can use short names for any system fonts
    serif = 'c:\\windows\\fonts\\timesi.ttf' #times in (genuine) italic
    comic = 'c:\\windows\\fonts\\comic.ttf' #comic
else:
    #Note that you must have a *.ttf font matching these names/paths
    #You can download ttf fonts free at http://www.webpagepublicity.com/free-fonts.html
    fancy = '/Library/Fonts/Impact.ttf'
    sans = '/Library/Fonts/Microsoft/Gill Sans MT.ttf'
    serif = '/Library/Fonts/Times New Roman.ttf'
    comic = '/Library/Fonts/Courier New.ttf'
    
#INITIALISE SOME STIMULI
fpsText = visual.TextStim(myWin, 
                        units='norm',height = 0.2,
                        pos=(-0.98, -0.98), text='starting...',
                        font=sans, 
                        alignHoriz = 'left',alignVert='bottom',
                        rgb=[+1,-1,-1])
rotating = visual.TextStim(myWin,text="Fonts rotate!",pos=(0, 0),
                        rgb=[-1.0,-1,1],
                        ori=0, height = 1,
                        font=comic,
                        alignHoriz='centre',alignVert='center') #NB you can spell centre in US or GB english ;-)
unicodeStuff = visual.TextStim(myWin,pos=(0, 2.5),
                        text = u"unicode (eg \u03A8 \u040A \u03A3)",#you can find the unicode character value from MS Word 'insert symbol'
                        italic=True, #use (fake) italics for whole string
                        rgb=-1,  font=serif,
                        height = 1.5)
psychopyTxt = visual.TextStim(myWin, 
                        text = u"PsychoPy \u00A9Jon Peirce",
                        units='norm', height=0.1,
                        pos=[0.95, 0.95], alignHoriz='right',alignVert='top',
                        font=fancy) #this may not exist but will be replaced with a default
                        
trialClock = core.Clock()
t=lastFPSupdate=0;
while t<20:#quits after 20 secs
    t=trialClock.getTime()
    
    rotating.setOri(0.1,"+")
    rotating.draw()
    
    unicodeStuff.draw()
    
    if t-lastFPSupdate>1:#update the fps every second
        fpsText.setText("%i fps" %myWin.fps())
        lastFPSupdate+=1
    fpsText.draw()
    psychopyTxt.draw()
    
    myWin.flip()

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.