/usr/share/pyshared/libopensesame/widgets/label.py is in opensesame 0.27.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | #-*- coding:utf-8 -*-
"""
This file is part of openexp.
openexp is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
openexp is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with openexp. If not, see <http://www.gnu.org/licenses/>.
"""
import textwrap
from widget import widget
class label(widget):
"""A simple non-interactive text label"""
def __init__(self, form, text='label', frame=False, center=True):
"""<DOC>
Constructor.
Arguments:
form -- The parent form.
Keyword arguments:
text -- A string of text (default='label').
frame -- Indicates whether a frame should be drawn around the widget #
(default=False).
center -- Indicates whether the text should be centered (default=True).
</DOC>"""
if type(frame) != bool:
frame = frame == u'yes'
if type(center) != bool:
center = center == u'yes'
widget.__init__(self, form)
self.type = u'label'
self.text = text
self.frame = frame
self.center = center
self.x_pad = 8
self.y_pad = 8
self.tab_str = u' ' # Replace tab characters by four spaces
def draw_text(self, text, html=True):
"""<DOC>
Draws text in the widget.
Arguments:
text -- The text to draw.
Keyword arguments:
html -- Indicates whether HTML should be parsed (default=True).
</DOC>"""
if self.form.item != None:
text = self.form.item.eval_text(text)
else:
text = self.form.experiment.eval_text(text)
text = self.form.experiment.unistr(text).replace('\t', self.tab_str)
x, y, w, h = self.rect
if self.center:
x += w/2
y += h/2
else:
x += self.x_pad
y += self.y_pad
w -= 2*self.x_pad
self.form.canvas.text(text, center=self.center, x=x, y=y, max_width=w, \
html=html)
def render(self):
"""<DOC>
Draws the widget.
</DOC>"""
if self.frame:
self.draw_frame(self.rect)
self.draw_text(self.text)
|