tuikit/checkbox.py
author Radek Brich <radek.brich@devl.cz>
Wed, 23 Jan 2013 00:50:23 +0100
changeset 65 5f0697950f15
parent 45 43b2279b06e1
child 77 fc1989059e19
permissions -rw-r--r--
DriverCurses: Add support for key modifiers.

# -*- coding: utf-8 -*-

from tuikit.button import Button


class Checkbox(Button):

    '''Checkbox - button.'''

    def __init__(self, label=''):
        Button.__init__(self, label)

        self.checked = False

        self.prefix = '[ ] '
        self.suffix = ''
        self.align = 'left'
        self.bg = 'normal'
        self.bghi = 'active'

    def on_click(self, ev):
        if self.checked:
            self.checked = False
            self.prefix = '[ ] '
        else:
            self.checked = True
            self.prefix = '[x] '