Package pyforms :: Package gui :: Package Controls :: Module ControlCheckBox |
[hide private]
[frames] | no frames]

# Source Code for Module pyforms.gui.Controls.ControlCheckBox

     1  #!/usr/bin/python
     2  # -*- coding: utf-8 -*-
     3
     4  __author__      = "Ricardo Ribeiro"
     5  __credits__     = ["Ricardo Ribeiro"]
     6  __license__     = "MIT"
     7  __version__     = "0.0"
     8  __maintainer__  = "Ricardo Ribeiro"
     9  __email__       = "ricardojvr@gmail.com"
    10  __status__      = "Development"
    11
    12
    13  import pyforms.Utils.tools as tools
    14  from PyQt4 import uic, QtGui
    15  from pyforms.gui.Controls.ControlBase import ControlBase
    16
    17 -class ControlCheckBox(ControlBase):
    18
    19 -    def initForm(self):
    20          control_path = tools.getFileInSameDirectory(__file__,"checkbox.ui")
    21          self._form = uic.loadUi( control_path )
    22          self._form.checkBox.setText(self._label)
    23          self._form.checkBox.stateChanged.connect(self.__checkedToggle)
    24
    25 -    def __checkedToggle(self): self.changed()
    26
    27 -    def load(self, data):
    28          if 'value' in data:
    29              self._form.checkBox.setChecked( data['value']=='True' )
    30
    31 -    def save(self, data):
    32          data['value'] = str( self.isChecked() )
    33
    34
    35      @property
    36 -    def value(self): return self._form.checkBox.isChecked()
    37
    38      @value.setter
    39 -    def value(self, value):
    40          ControlBase.value.fset(self,value)
    41          self._form.checkBox.setChecked(value)
    42