Beispiel #1
0
	def __init__(self, experiment, cols=2, rows=2, spacing=10, margins=(100, 100, 100, 100), theme=u'gray', item=None):

		"""<DOC>
		Constructor

		Arguments:
		experiment -- An OpenSesame experiment.

		Keyword arguments:
		cols -- The number of columns (as int) or a list that specifies the #
				number and relative size of the columns. For example, '[1,2,1]' #
				will create 3 columns where the middle one is twice as large as #
				the outer ones (default=2).
		rows -- Analogous to 'cols' (default=2).
		spacing -- The amount of empty space between the widgets (default=10).
		margins -- The amount of empty space around the form. This is specified #
				   as a list, like so [top-margin, right-margin, bottom-margin, #
				   left-margin] (default=[100, 100, 100, 100]).
		theme -- The theme for the widgets (default='gray').
		item -- The item of which the form is part (default=None).
		</DOC>"""

		# Normalize the column and row sizes so that they add up to 1
		if type(cols) == int:
			self.cols = [1./cols]*cols
		else:
			cols = type_check.float_list(cols, u'form columns', min_len=1)
			self.cols = [float(c)/sum(cols) for c in cols]
		if type(rows) == int:
			self.rows = [1./rows]*rows
		else:
			rows = type_check.float_list(rows, u'form rows', min_len=1)
			self.rows = [float(r)/sum(rows) for r in rows]

		self.experiment = experiment
		if item != None:
			self.item = item
		else:
			self.item = experiment
		self.width = experiment.get(u'width')
		self.height = experiment.get(u'height')
		self.spacing = spacing
		self.margins = type_check.float_list(margins, u'form margins', \
			min_len=4, max_len=4)
		n_cells = len(self.cols)*len(self.rows)
		self.widgets = [None]*n_cells
		self.span = [(1,1)]*n_cells
		self.canvas = canvas(self.experiment, auto_prepare=False, fgcolor= \
			self.item.get(u'foreground'), bgcolor=self.item.get( \
			u'background'))

		if theme == u'gray':
			from themes.gray import gray
			self.theme_engine = gray(self)
		else:
			from themes.plain import plain
			self.theme_engine = plain(self)
Beispiel #2
0
    def __init__(self,
                 experiment,
                 cols=2,
                 rows=2,
                 spacing=10,
                 margins=(100, 100, 100, 100),
                 theme='gray',
                 item=None):
        """<DOC>		
		Constructor
		
		Arguments:
		experiment -- an OpenSesame experiment
		
		Keyword arguments:
		cols -- The number of columns (as int) or a list that specifies the
				number and relative size of the columns. For example, '[1,2,1]'
				will create 3 columns where the middle one is twice as large as
				the outer ones. (default=2)
		rows -- Analogous to 'cols' (default=2)
		spacing -- The amount of empty space between the widgets (default=10)
		margins -- The amount of empty space around the form. This is specified
				   as a list, like so [top-margin, right-margin, bottom-margin,
				   left-margin]. (default=[100, 100, 100, 100])
		theme -- the theme for the widgets (default='gray')
		item -- the item of which the form is part (default=None)
		</DOC>"""

        # Normalize the column and row sizes so that they add up to 1
        if type(cols) == int:
            self.cols = [1. / cols] * cols
        else:
            self.cols = [float(c) / sum(cols) for c in cols]
        if type(rows) == int:
            self.rows = [1. / rows] * rows
        else:
            self.rows = [float(r) / sum(rows) for r in rows]

        self.experiment = experiment
        self.item = item
        self.width = experiment.get('width')
        self.height = experiment.get('height')
        self.spacing = spacing
        self.margins = margins
        n_cells = len(self.cols) * len(self.rows)
        self.widgets = [None] * n_cells
        self.span = [(1, 1)] * n_cells
        self.canvas = canvas(self.experiment, auto_prepare=False)

        if theme == 'gray':
            from themes.gray import gray
            self.theme_engine = gray(self)
        else:
            from themes.plain import plain
            self.theme_engine = plain(self)
Beispiel #3
0
	def __init__(self, experiment, cols=2, rows=2, spacing=10, margins=(100, 100, 100, 100), theme='gray', item=None):
		
		"""<DOC>		
		Constructor
		
		Arguments:
		experiment -- an OpenSesame experiment
		
		Keyword arguments:
		cols -- The number of columns (as int) or a list that specifies the
				number and relative size of the columns. For example, '[1,2,1]'
				will create 3 columns where the middle one is twice as large as
				the outer ones. (default=2)
		rows -- Analogous to 'cols' (default=2)
		spacing -- The amount of empty space between the widgets (default=10)
		margins -- The amount of empty space around the form. This is specified
				   as a list, like so [top-margin, right-margin, bottom-margin,
				   left-margin]. (default=[100, 100, 100, 100])
		theme -- the theme for the widgets (default='gray')
		item -- the item of which the form is part (default=None)
		</DOC>"""
				
		# Normalize the column and row sizes so that they add up to 1
		if type(cols) == int:
			self.cols = [1./cols]*cols
		else:
			self.cols = [float(c)/sum(cols) for c in cols]
		if type(rows) == int:
			self.rows = [1./rows]*rows			
		else:	
			self.rows = [float(r)/sum(rows) for r in rows]			
	
		self.experiment = experiment
		self.item = item
		self.width = experiment.get('width')
		self.height = experiment.get('height')		
		self.spacing = spacing
		self.margins = margins
		n_cells = len(self.cols)*len(self.rows)
		self.widgets = [None]*n_cells
		self.span = [(1,1)]*n_cells	
		self.canvas = canvas(self.experiment, auto_prepare=False)		
		
		if theme == 'gray':
			from themes.gray import gray
			self.theme_engine = gray(self)
		else:
			from themes.plain import plain
			self.theme_engine = plain(self)			
Beispiel #4
0
    def __init__(self,
                 experiment,
                 cols=2,
                 rows=2,
                 spacing=10,
                 margins=(100, 100, 100, 100),
                 theme=u'gray',
                 item=None):
        """
		desc:
			Constructor.

		arguments:
			experiment:
				desc:	An OpenSesame experiment.
				type:	experiment

		keywords:
			cols:
				desc:	The number of columns (as int) or a list that specifies
						the number and relative size of the columns. For
						example, `[1,2,1]` will create 3 columns where the
						middle one is twice as large as the outer ones.
				type:	[int, list]
			rows:
				desc:	Analogous to `cols`, but for the rows.
				type:	[int, list]
			spacing:
				desc:	The amount of empty space between widgets (in pixels).
				type:	int
			margins:
				desc:	The amount of empty space around the form. This is
						specified as a list, like so [top-margin, right-margin,
						bottom-margin, left-margin].
				type:	list
			theme:
				desc:	The theme for the widgets.
				type:	[str, unicode]
			item:
				desc:	The item of which the form is part.
				type:	[item, NoneType]
		"""

        # Normalize the column and row sizes so that they add up to 1
        if type(cols) == int:
            self.cols = [1. / cols] * cols
        else:
            cols = type_check.float_list(cols, u'form columns', min_len=1)
            self.cols = [float(c) / sum(cols) for c in cols]
        if type(rows) == int:
            self.rows = [1. / rows] * rows
        else:
            rows = type_check.float_list(rows, u'form rows', min_len=1)
            self.rows = [float(r) / sum(rows) for r in rows]

        self.experiment = experiment
        if item != None:
            self.item = item
        else:
            self.item = experiment
        self.width = experiment.get(u'width')
        self.height = experiment.get(u'height')
        self.spacing = spacing
        self.margins = type_check.float_list(margins, u'form margins', \
         min_len=4, max_len=4)
        n_cells = len(self.cols) * len(self.rows)
        self.widgets = [None] * n_cells
        self.span = [(1, 1)] * n_cells
        self.canvas = canvas(self.experiment, auto_prepare=False, fgcolor= \
         self.item.get(u'foreground'), bgcolor=self.item.get( \
         u'background'))

        if theme == u'gray':
            from themes.gray import gray
            self.theme_engine = gray(self)
        else:
            from themes.plain import plain
            self.theme_engine = plain(self)
Beispiel #5
0
	def __init__(self, experiment, cols=2, rows=2, spacing=10,
		margins=(100, 100, 100, 100), theme=u'gray', item=None):

		"""
		desc:
			Constructor.

		arguments:
			experiment:
				desc:	An OpenSesame experiment.
				type:	experiment

		keywords:
			cols:
				desc:	The number of columns (as int) or a list that specifies
						the number and relative size of the columns. For
						example, `[1,2,1]` will create 3 columns where the
						middle one is twice as large as the outer ones.
				type:	[int, list]
			rows:
				desc:	Analogous to `cols`, but for the rows.
				type:	[int, list]
			spacing:
				desc:	The amount of empty space between widgets (in pixels).
				type:	int
			margins:
				desc:	The amount of empty space around the form. This is
						specified as a list, like so [top-margin, right-margin,
						bottom-margin, left-margin].
				type:	list
			theme:
				desc:	The theme for the widgets.
				type:	[str, unicode]
			item:
				desc:	The item of which the form is part.
				type:	[item, NoneType]
		"""

		# Normalize the column and row sizes so that they add up to 1
		if type(cols) == int:
			self.cols = [1./cols]*cols
		else:
			cols = type_check.float_list(cols, u'form columns', min_len=1)
			self.cols = [float(c)/sum(cols) for c in cols]
		if type(rows) == int:
			self.rows = [1./rows]*rows
		else:
			rows = type_check.float_list(rows, u'form rows', min_len=1)
			self.rows = [float(r)/sum(rows) for r in rows]

		self.experiment = experiment
		if item != None:
			self.item = item
		else:
			self.item = experiment
		self.width = experiment.get(u'width')
		self.height = experiment.get(u'height')
		self.spacing = spacing
		self.margins = type_check.float_list(margins, u'form margins', \
			min_len=4, max_len=4)
		n_cells = len(self.cols)*len(self.rows)
		self.widgets = [None]*n_cells
		self.span = [(1,1)]*n_cells
		self.canvas = canvas(self.experiment, auto_prepare=False, fgcolor= \
			self.item.get(u'foreground'), bgcolor=self.item.get( \
			u'background'))

		if theme == u'gray':
			from themes.gray import gray
			self.theme_engine = gray(self)
		else:
			from themes.plain import plain
			self.theme_engine = plain(self)