Logo Search packages:      
Sourcecode: quickly-widgets version File versions  Download package

press_and_hold_button.py

### BEGIN LICENSE
# Copyright (C) 2010 Rick Spencer rick.spencer@canonical.com
#This program is free software: you can redistribute it and/or modify it 
#under the terms of the GNU General Public License version 3, as published 
#by the Free Software Foundation.
#
#This program is distributed in the hope that it will be useful, but 
#WITHOUT ANY WARRANTY; without even the implied warranties of 
#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
#PURPOSE.  See the GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License along 
#with this program.  If not, see <http://www.gnu.org/licenses/>.
### END LICENSE

import gobject
import gtk

class PressAndHoldButton(gtk.Button):
    def __init__(self):
        gtk.Button.__init__(self)
        self.connect("pressed",self.__pressed)
        self.connect("released",self.__released)
        self.__continue_ticking = True

    def __pressed(self, widget, data=None):
        self.__continue_ticking = True
        widget.emit("tick",self)
        gobject.timeout_add(250, self.__tick)

    def __released(self, widget, data=None):
        self.__continue_ticking = False

    def __tick(self, data=None):
        if self.__continue_ticking:
            self.emit("tick",self)
        return self.__continue_ticking

    __gsignals__ = {'tick' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
            (gobject.TYPE_PYOBJECT,)),
            }


Generated by  Doxygen 1.6.0   Back to index