Package Camelot :: Package camelot :: Package view :: Package controls :: Package editors :: Module textlineeditor |
[frames] | no frames]

# Source Code for Module Camelot.camelot.view.controls.editors.textlineeditor

     1  from PyQt4 import QtGui
     2

     3  from customeditor import AbstractCustomEditor
     4

     5 -class TextLineEditor(QtGui.QLineEdit, AbstractCustomEditor):
     6

     7 -    def __init__(self, parent, length=20, editable=True, **kwargs):
     8          QtGui.QLineEdit.__init__(self, parent)
     9          AbstractCustomEditor.__init__(self)
    10          if length:
    11              self.setMaxLength(length)
    12          if not editable:
    13              self.setEnabled(False)
    14

    15 -    def set_value(self, value):
    16          value = AbstractCustomEditor.set_value(self, value)
    17          if value:
    18              self.setText(unicode(value))
    19          else:
    20              self.setText('')
    21

    22 -    def get_value(self):
    23          return AbstractCustomEditor.get_value(self) or unicode(self.text())
    24

    25 -    def set_enabled(self, editable=True):
    26          value = self.text()
    27          self.setEnabled(editable)
    28          self.setText(value)
    29