Repository navigation
Expand file tree
/
Copy pathControlText.py
More file actions
66 lines (51 loc) · 1.8 KB
/
Copy pathControlText.py
File metadata and controls
66 lines (51 loc) · 1.8 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
#!/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
@lastEditedBy: Carlos Mão de Ferro (carlos.maodeferro@neuro.fchampalimaud.org)
'''
import pyforms.utils.tools as tools
from pyforms.gui.controls.ControlBase import ControlBase
from AnyQt.QtWidgets import QLineEdit
from AnyQt import uic
class ControlText(ControlBase):
def init_form(self):
control_path = tools.getFileInSameDirectory(__file__, "textInput.ui")
self._form = uic.loadUi(control_path)
self.form.label.setText(self._label)
if self._value is not None: self.form.lineEdit.setText(self._value)
self.form.setToolTip(self.help)
super(ControlText, self).init_form()
self.form.label.setAccessibleName('ControlText-label')
self.form.lineEdit.editingFinished.connect(self.finishEditing)
self.form.lineEdit.keyPressEvent = self.__key_pressed
def finishEditing(self):
"""Function called when the lineEdit widget is edited"""
self.changed_event()
def __key_pressed(self, event):
QLineEdit.keyPressEvent(self.form.lineEdit, event)
self.key_pressed_event(event)
def key_pressed_event(self, evt): pass
###################################################################
############ Properties ###########################################
###################################################################
@property
def value(self):
self._value = str(self._form.lineEdit.text())
return self._value
@value.setter
def value(self, value):
self._form.lineEdit.setText(value)
ControlBase.value.fset(self, value)
@property
def label(self): return self.form.label.text()
@label.setter
def label(self, value):
self.form.label.setText(value)
ControlBase.label.fset(self, value)