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

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

     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  @lastEditedBy: Carlos Mão de Ferro (carlos.maodeferro@neuro.fchampalimaud.org)
    12  '''
    13
    14  import pyforms.Utils.tools as tools
    15  from PyQt4 import uic
    16  from pyforms.gui.Controls.ControlBase import ControlBase
    17
    18
    19 -class ControlButton(ControlBase):
    20
    21 -    def __init__(self, label='', checkable=False):
    22          self._checkable = checkable
    23          super(ControlButton, self).__init__(label)
    24
    25 -    def initForm(self):
    26          control_path = tools.getFileInSameDirectory(__file__, "button.ui")
    27          self._form = uic.loadUi(control_path)
    28          self._form.pushButton.setText(self._label)
    29          self._form.pushButton.setCheckable(self._checkable)
    30          self.tooltip = None
    31
    32 -    def load(self, data): pass
    33
    34 -    def save(self, data): pass
    35
    36      ##########################################################################
    37
    38      @property
    39 -    def label(self):
    40          return ControlBase.label.fget(self)
    41
    42      @label.setter
    43 -    def label(self, value):
    44          ControlBase.label.fset(self, value)
    45          self._form.pushButton.setText(self._label)
    46
    47      ##########################################################################
    48
    49      @property
    50 -    def value(self):
    51          return None
    52
    53      @value.setter
    54 -    def value(self, value):
    55          self._form.pushButton.clicked[bool].connect(value)
    56
    57
    58      @property
    59 -    def checked(self):
    60          return self._form.pushButton.isChecked()
    61
    62      @checked.setter
    63 -    def checked(self, value):
    64          self._form.pushButton.setChecked(value)
    65
    66 -    def click(self):
    67          self._form.pushButton.click()
    68