Skip to content

Commit

Permalink
Merge 2053d50 into ae519ab
Browse files Browse the repository at this point in the history
  • Loading branch information
TEParsons committed Mar 17, 2021
2 parents ae519ab + 2053d50 commit dc86ee1
Show file tree
Hide file tree
Showing 44 changed files with 488 additions and 550 deletions.
635 changes: 278 additions & 357 deletions psychopy/app/builder/builder.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions psychopy/experiment/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ def getComponents(folder=None, fetchIcons=True):

if hasattr(module, 'tooltip'):
tooltips[name] = module.tooltip
if hasattr(module, 'iconFile'):
iconFiles[name] = module.iconFile
if hasattr(components[attrib], 'iconFile'):
iconFiles[name] = components[attrib].iconFile
# assign the module categories to the Component
if not hasattr(components[attrib], 'categories'):
components[attrib].categories = ['Custom']
Expand Down
10 changes: 8 additions & 2 deletions psychopy/experiment/components/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ class BaseComponent(object):
"""A template for components, defining the methods to be overridden"""
# override the categories property below
# an attribute of the class, determines the section in the components panel

categories = ['Custom']
targets = ['PsychoPy']
targets = []
iconFile = ""
tooltip = ""

def __init__(self, exp, parentName, name='',
startType='time (s)', startVal='',
Expand Down Expand Up @@ -574,8 +577,11 @@ def getShortType(self):
class BaseVisualComponent(BaseComponent):
"""Base class for most visual stimuli
"""
# an attribute of the class, determines section in the components panel

categories = ['Stimuli']
targets = []
iconFile = ""
tooltip = ""

def __init__(self, exp, parentName, name='',
units='from exp settings', color='white', fillColor="", borderColor="",
Expand Down
13 changes: 7 additions & 6 deletions psychopy/experiment/components/aperture/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from builtins import super # provides Py3-style super() using python-future

from os import path
from pathlib import Path
from psychopy.experiment.components import BaseVisualComponent, getInitVals, _translate
from psychopy.localization import _localized as __localized
_localized = __localized.copy()
Expand All @@ -17,17 +18,17 @@
# March 2011; builder-component for Yuri Spitsyn's visual.Aperture class
# July 2011: jwp added the code for it to be enabled only when needed

# the absolute path to the folder containing this path
thisFolder = path.abspath(path.dirname(__file__))
iconFile = path.join(thisFolder, 'aperture.png')
tooltip = _translate('Aperture: restrict the drawing of stimuli to a given '
'region')


class ApertureComponent(BaseVisualComponent):
"""An event class for using GL stencil to restrict the viewing area to a
circle or square of a given size and position"""

categories = ['Stimuli']
targets = ['PsychoPy']
iconFile = Path(__file__).parent / 'aperture.png'
tooltip = _translate('Aperture: restrict the drawing of stimuli to a given '
'region')

def __init__(self, exp, parentName, name='aperture', units='norm',
size=1, pos=(0, 0),
startType='time (s)', startVal=0.0,
Expand Down
10 changes: 4 additions & 6 deletions psychopy/experiment/components/brush/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@

from builtins import str
from os import path
from pathlib import Path
from psychopy.experiment.components import BaseVisualComponent, Param, getInitVals, _translate
from psychopy import logging
from psychopy.localization import _localized as __localized
_localized = __localized.copy()

# the absolute path to the folder containing this path
thisFolder = path.abspath(path.dirname(__file__))
iconFile = path.join(thisFolder, 'brush.png')
tooltip = _translate('Brush: a drawing tool')

# only use _localized values for label values, nothing functional:
_localized.update({'lineWidth': _translate('Brush Size'),
'lineColor': _translate('Brush Color'),
Expand All @@ -29,6 +25,9 @@ class BrushComponent(BaseVisualComponent):
"""A class for drawing freehand responses"""

categories = ['Responses']
targets = ['PsychoPy', 'PsychoJS']
iconFile = Path(__file__).parent / 'brush.png'
tooltip = _translate('Brush: a drawing tool')

def __init__(self, exp, parentName, name='brush',
lineColor='$[1,1,1]', lineColorSpace='rgb',
Expand All @@ -46,7 +45,6 @@ def __init__(self, exp, parentName, name='brush',
self.type = 'Brush'
self.url = "https://www.psychopy.org/builder/components/brush.html"
self.exp.requirePsychopyLibs(['visual'])
self.targets = ['PsychoPy', 'PsychoJS']
self.order.remove("opacity") # Move opacity to the end
self.order += [
"lineWidth", "lineColor", "lineColorSpace", "opacity" # Appearance tab
Expand Down
8 changes: 3 additions & 5 deletions psychopy/experiment/components/button/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@
# Distributed under the terms of the GNU General Public License (GPL).

from os import path
from pathlib import Path

from psychopy.alerts import alerttools
from psychopy.experiment.components import BaseVisualComponent, Param, getInitVals, _translate
from psychopy.localization import _localized as __localized
_localized = __localized.copy()

# the absolute path to the folder containing this path
thisFolder = path.abspath(path.dirname(__file__))
iconFile = path.join(thisFolder, 'button.png')
tooltip = _translate('Button: A clickable textbox')

# only use _localized values for label values, nothing functional:
_localized.update({'callback': _translate("Callback Function"),
'forceEndRoutine': _translate('Force end of Routine'),
Expand All @@ -42,6 +38,8 @@ class ButtonComponent(BaseVisualComponent):
"""
categories = ['Responses']
targets = ['PsychoPy']
iconFile = Path(__file__).parent / 'button.png'
tooltip = _translate('Button: A clickable textbox')

def __init__(self, exp, parentName, name="button",
startType='time (s)', startVal=0.1,
Expand Down
10 changes: 4 additions & 6 deletions psychopy/experiment/components/cedrusBox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from builtins import str
from past.builtins import basestring
from os import path
from pathlib import Path

from psychopy.constants import PY3
from psychopy.experiment.components import Param, _translate
Expand All @@ -19,12 +20,6 @@
_localized = __localized.copy()
__author__ = 'Jon Peirce'

# abs path to the folder containing this path
thisFolder = path.abspath(path.dirname(__file__))
iconFile = path.join(thisFolder, 'cedrusBox.png')
tooltip = _translate('Cedrus Button Box: Cedrus response boxes, using the '
'pyxid library provided by Cedrus')

# only use _localized values for label values, nothing functional:
_localized.update({'deviceNumber': _translate('Device number'),
'useBoxTimer': _translate("Use box timer")})
Expand All @@ -43,6 +38,9 @@ class cedrusButtonBoxComponent(KeyboardComponent):
"""
categories = ['Responses'] # which section(s) in the components panel
targets = ['PsychoPy']
iconFile = Path(__file__).parent / 'cedrusBox.png'
tooltip = _translate('Cedrus Button Box: Cedrus response boxes, using the '
'pyxid library provided by Cedrus')

def __init__(self, exp, parentName, name='buttonBox',
store='first key',
Expand Down
13 changes: 6 additions & 7 deletions psychopy/experiment/components/code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@

from builtins import str
from os import path
from pathlib import Path

from psychopy import prefs
from psychopy.experiment.components import BaseComponent, Param, _translate
from psychopy.alerts import alerttools

# the absolute path to the folder containing this path
thisFolder = path.abspath(path.dirname(__file__))
iconFile = path.join(thisFolder, 'code.png')
tooltip = _translate('Code: insert python commands into an experiment')
_localized = {'Code Type': _translate('Code Type'),
'Before Experiment': _translate('Before Experiment'),
'Begin Experiment': _translate('Begin Experiment'),
Expand All @@ -35,10 +32,13 @@


class CodeComponent(BaseComponent):
# an attribute of the class, determines the section in the components panel
categories = ['Custom']
"""An event class for inserting arbitrary code into Builder experiments"""

categories = ['Custom']
targets = ['PsychoPy', 'PsychoJS']
iconFile = Path(__file__).parent / 'code.png'
tooltip = _translate('Code: insert python commands into an experiment')

def __init__(self, exp, parentName, name='code',
beforeExp="",
beginExp="",
Expand All @@ -49,7 +49,6 @@ def __init__(self, exp, parentName, name='code',
codeType=None, translator="manual"):
super(CodeComponent, self).__init__(exp, parentName, name)
self.type = 'Code'
self.targets = ['PsychoPy', 'PsychoJS']
self.url = "https://www.psychopy.org/builder/components/code.html"
# params
# want a copy, else codeParamNames list gets mutated
Expand Down
10 changes: 6 additions & 4 deletions psychopy/experiment/components/dots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@
from __future__ import absolute_import, print_function

from os import path
from pathlib import Path
from psychopy.experiment.components import BaseVisualComponent, Param, getInitVals, _translate
from psychopy.localization import _localized as __localized
_localized = __localized.copy()

# the absolute path to the folder containing this path
thisFolder = path.abspath(path.dirname(__file__))
iconFile = path.join(thisFolder, 'dots.png')
tooltip = _translate('Dots: Random Dot Kinematogram')
# only use _localized values for label values, nothing functional:
_localized.update({'nDots': _translate('Number of dots'),
'dir': _translate('Direction'),
Expand All @@ -34,6 +31,11 @@
class DotsComponent(BaseVisualComponent):
"""An event class for presenting Random Dot stimuli"""

categories = ['Stimuli']
targets = ['PsychoPy']
iconFile = Path(__file__).parent / 'dots.png'
tooltip = _translate('Dots: Random Dot Kinematogram')

def __init__(self, exp, parentName, name='dots',
nDots=100,
direction=0.0, speed=0.1, coherence=1.0,
Expand Down
11 changes: 7 additions & 4 deletions psychopy/experiment/components/emotiv_marking/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from __future__ import absolute_import, print_function

from os import path
from pathlib import Path
from psychopy.experiment.components import (BaseComponent, Param, getInitVals,
_translate)
# overwrite (filemode='w') a detailed log of the last run in this dir
Expand All @@ -15,16 +16,18 @@
from psychopy.localization import _localized as __localized
_localized = __localized.copy()

thisFolder = path.abspath(path.dirname(__file__))
iconFile = path.join(thisFolder, 'emotiv_marking.png')
tooltip = _translate('Mark a period of EEG')

_localized.update({'marker_label': _translate('Marker Label'),
'marker_value': _translate('Marker Value'),
'stop_marker': _translate('Stop Marker')})


class EmotivMarkingComponent(BaseComponent): # or (VisualComponent)

categories = ['Custom']
targets = ['PsychoPy']
iconFile = Path(__file__).parent / 'emotiv_marking.png'
tooltip = _translate('Mark a period of EEG')

def __init__(self, exp, parentName, name='eeg_marker',
startType='time (s)', startVal=0.0,
stopType='duration (s)', stopVal=1,
Expand Down
11 changes: 7 additions & 4 deletions psychopy/experiment/components/emotiv_record/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
@author: mrbki
"""
from os import path
from pathlib import Path
from psychopy.experiment.components import BaseComponent, getInitVals
from psychopy.localization import _translate, _localized as __localized
_localized = __localized.copy()

CORTEX_OBJ = 'cortex_obj'

thisFolder = path.abspath(path.dirname(__file__))
iconFile = path.join(thisFolder, 'emotiv_record.png')
tooltip = _translate('Initialize EMOTIV hardware connection')


class EmotivRecordingComponent(BaseComponent): # or (VisualComponent)

categories = ['Custom']
targets = ['PsychoPy']
iconFile = Path(__file__).parent / 'emotiv_record.png'
tooltip = _translate('Initialize EMOTIV hardware connection')

def __init__(self, exp, parentName, name='cortex_rec'):
super(EmotivRecordingComponent, self).__init__(
exp, parentName, name=name,
Expand Down
13 changes: 7 additions & 6 deletions psychopy/experiment/components/envelopegrating/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,11 @@
from builtins import super # provides Py3-style super() using python-future

from os import path
from pathlib import Path
from psychopy.experiment.components import BaseVisualComponent, Param, getInitVals, _translate
from psychopy.localization import _localized as __localized
_localized = __localized.copy()

# the absolute path to the folder containing this path
thisFolder = path.abspath(path.dirname(__file__))
iconFile = path.join(thisFolder, 'envelopegrating.png')
tooltip = _translate('Envelope Grating: present cyclic textures including 2nd order envelope stimuli, prebuilt or from a '
'file')

# only use _localized values for label values, nothing functional:
_localized.update({'carrier': _translate('Carrier texture'),
'ori': _translate('Carrier Orientation'),
Expand All @@ -41,6 +36,12 @@
class EnvGratingComponent(BaseVisualComponent):
"""A class for presenting grating stimuli"""

categories = ['Stimuli']
targets = ['PsychoPy']
iconFile = Path(__file__).parent / 'envelopegrating.png'
tooltip = _translate('Envelope Grating: present cyclic textures including 2nd order envelope stimuli, '
'prebuilt or from a file')

def __init__(self, exp, parentName, name='env_grating', carrier='sin',
mask='None', sf=1.0, interpolate='linear',
units='from exp settings', color='$[1,1,1]', colorSpace='rgb',
Expand Down
11 changes: 5 additions & 6 deletions psychopy/experiment/components/eyetracker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,19 @@
from builtins import super # provides Py3-style super() using python-future

from os import path
from pathlib import Path
from psychopy.experiment.components import BaseComponent, Param, _translate
from psychopy.localization import _localized as __localized
_localized = __localized.copy()

# the absolute path to the folder containing this path
thisFolder = path.abspath(path.dirname(__file__))
iconFile = path.join(thisFolder, 'eyetracker.png')
tooltip = _translate('Eyetracker: use one of several eyetrackers to follow '
'gaze')


class EyetrackerComponent(BaseComponent):
"""A class for using one of several eyetrackers to follow gaze"""
categories = ['Responses']
targets = ['PsychoPy']
iconFile = Path(__file__).parent / 'eyetracker.png'
tooltip = _translate('Eyetracker: use one of several eyetrackers to follow '
'gaze')

def __init__(self, exp, parentName, name='eyes',
startType='time (s)', startVal=0.0,
Expand Down
9 changes: 4 additions & 5 deletions psychopy/experiment/components/form/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@
from __future__ import absolute_import, print_function

from os import path
from pathlib import Path
from psychopy.experiment.components import Param, getInitVals, _translate, BaseVisualComponent
from psychopy.visual import form
from psychopy.localization import _localized as __localized
_localized = __localized.copy()

__author__ = 'Jon Peirce, David Bridges, Anthony Haffey'

# the absolute path to the folder containing this path
thisFolder = path.abspath(path.dirname(__file__))
iconFile = path.join(thisFolder, 'form.png')
tooltip = _translate('Form: a Psychopy survey tool')

# only use _localized values for label values, nothing functional:
_localized.update({'Items': _translate('Items'),
'Text Height': _translate('Text Height'),
Expand All @@ -30,11 +26,14 @@
})
knownStyles = form.Form.knownStyles


class FormComponent(BaseVisualComponent):
"""A class for presenting a survey as a Builder component"""

categories = ['Responses']
targets = ['PsychoPy', 'PsychoJS']
iconFile = Path(__file__).parent / 'form.png'
tooltip = _translate('Form: a Psychopy survey tool')

def __init__(self, exp, parentName,
name='form',
Expand Down
Loading

0 comments on commit dc86ee1

Please sign in to comment.