Repository navigation
Expand file tree
/
Copy pathControlTextArea.py
More file actions
71 lines (51 loc) · 1.78 KB
/
Copy pathControlTextArea.py
File metadata and controls
71 lines (51 loc) · 1.78 KB
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = "Ricardo Ribeiro"
__credits__ = ["Ricardo Ribeiro"]
__license__ = "MIT"
__version__ = "0.0"
__maintainer__ = "Ricardo Ribeiro"
__email__ = "ricardojvr@gmail.com"
__status__ = "Development"
import pyforms.utils.tools as tools
from AnyQt import uic, QtGui
from pyforms.gui.controls.ControlBase import ControlBase
class ControlTextArea(ControlBase):
def __init__(self, *args, **kwargs):
ControlBase.__init__(self, *args, **kwargs)
self.autoscroll = kwargs.get('autoscroll', False)
def init_form(self):
control_path = tools.getFileInSameDirectory(__file__, "textArea.ui")
self._form = uic.loadUi(control_path)
self._form.label.setText(self._label)
if self._value:
self._form.plainTextEdit.setPlainText(str(self._value))
if not self._label or len(self._label)==0:
self.form.label.hide()
super(ControlTextArea, self).init_form()
self.form.plainTextEdit.textChanged.connect(self.finishEditing)
def __add__(self, other):
self._form.plainTextEdit.appendPlainText(str(other))
# if activated the text field is autoscrolled to the bottom
if self.autoscroll:
self._form.plainTextEdit.moveCursor(QtGui.QTextCursor.End)
return self
def finishEditing(self):
"""Function called when the lineEdit widget is edited"""
self.changed_event()
@property
def value(self):
return self._form.plainTextEdit.toPlainText()
@value.setter
def value(self, value):
self._form.plainTextEdit.setPlainText(str(value))
@property
def readonly(self):
return self._form.plainTextEdit.isReadOnly()
@readonly.setter
def readonly(self, value):
self._form.plainTextEdit.setReadOnly(value)
@property
def autoscroll(self): return self._autoscroll
@autoscroll.setter
def autoscroll(self, value): self._autoscroll = value