Skip to content

Commit

Permalink
Added selectable to ControlLabel and readonly to ControlText
Browse files Browse the repository at this point in the history
  • Loading branch information
MicBoucinha committed Nov 22, 2018
1 parent 7ec4114 commit 557467d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pyforms_gui/controls/control_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@

class ControlLabel(ControlBase):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.selectable = kwargs.get('selectable', False)

def init_form(self):
control_path = tools.getFileInSameDirectory(__file__, "label.ui")
self._form = uic.loadUi(control_path)
self._form.label.setText(self._label)
self._selectable = False
super(ControlLabel, self).init_form()

def load_form(self, data, path=None): pass
Expand All @@ -38,7 +41,8 @@ def selectable(self): return self._selectable

@selectable.setter
def selectable(self, value):
if value:
self._selectable = value
if self._selectable:
self._form.label.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
self._form.label.setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor))
else:
Expand All @@ -48,7 +52,6 @@ def selectable(self, value):
@property
def form(self): return self._form


@property
def value(self): return ControlBase.value.fget(self)

Expand Down
5 changes: 5 additions & 0 deletions pyforms_gui/controls/control_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@
from AnyQt.QtWidgets import QLineEdit
from AnyQt import uic


class ControlText(ControlBase):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.readonly = kwargs.get('readonly', False)

def init_form(self):
control_path = tools.getFileInSameDirectory(__file__, "textInput.ui")
self._form = uic.loadUi(control_path)
Expand Down

0 comments on commit 557467d

Please sign in to comment.