示例#1
0
from psychopy.visual.textbox2 import TextBox2, allFonts

arial = "Arial Unicode MS"
arial = "Arial"

win = visual.Window([800, 800], monitor='testMonitor', backend='glfw')
logging.exp("{:.3f}: created window".format(c.getTime()))

text = u"<i>The quick</i> brown <b>fox</b> jumped"
text2 = u"Some text in Times"
loremIpsum = u"PsychoPy is an open-source Python application allowing you to run a supercali-fragilisticexpeilidocious wide range of neuroscience, psychology and psychophysics experiments. It’s a free, powerful alternative to Presentation™ or e-Prime™, written in Python (a free alternative to Matlab™ g)."

fontSize = 16
# preload some chars into a font to see how long it takes
nChars = 256
arial = allFonts.getFont(arial, fontSize)
logging.exp("{:.3f}: created font".format(c.getTime()))
arial.preload(nChars)
logging.exp("{:.3f}: preloaded {} chars".format(c.getTime(), nChars))
# arial.saveToCache()  # can't yet retrieve the font but it's interesting to see!
logging.flush()

txt1 = TextBox2(win,
                color=[0.5, 0, 0, 0],
                text='Toptastic',
                font='Times',
                pos=(-1, 4),
                letterHeight=2,
                units='deg',
                anchor='right',
                borderColor='red',
示例#2
0
from psychopy import visual, core, event, logging
import numpy as np

logging.console.setLevel(logging.EXP)
c = core.Clock()

from psychopy.visual.textbox2 import TextBox2, allFonts

win = visual.Window([800, 800], monitor='testMonitor')
logging.exp("{:.3f}: created window".format(c.getTime()))

psychopyInfo = u"<b>PsychoPy</b> is an <i>open-source</i> Python application allowing you to run a supercali-fragilisticexpeilidocious wide range of neuroscience, psychology and psychophysics experiments. It’s a free, powerful alternative to Presentation™ or e-Prime™, written in Python (a free alternative to Matlab™ g)."

# preload some chars into a font to see how long it takes
fontSize = 16
arial = allFonts.getFont("Arial", fontSize)
logging.exp("{:.3f}: created font".format(c.getTime()))
nChars = 256
arial.preload(nChars)  # or set to preload specific string of chars
logging.exp("{:.3f}: preloaded {} chars".format(c.getTime(), nChars))

txt1 = TextBox2(win,
                text="Type here, it's toptastic",
                font='Times',
                color='black',
                colorSpace='named',
                pos=(0, 0.4),
                letterHeight=0.05,
                units='height',
                size=[0.8, 0.2],
                anchor='center-top',