<s> from PyQt5 . QtCore import Qt , QTimer <EOL> f = lambda * args , ** kwargs : None <EOL> class CoubletMouseEventHandler : <EOL> def __init__ ( self , interval = <NUM_LIT> , l_single = f , l_double = f , r_single = f , r_double = f ) : <EOL> self . l_timer = l_timer = QTimer ( ) <EOL> self . r_timer = r_timer = QTimer ( ) <EOL> for i , side in enumerate ( ( l_timer , r_timer ) ) : <EOL> side . setInterval ( interval ) <EOL> side . setSingleShot ( True ) <EOL> side . timeout . connect ( lambda s = i : self . _on_timeout ( s ) ) <EOL> self . _counters = [ <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> self . _singles = [ l_single , r_single ] <EOL> self . _doubles = [ l_double , r_double ] <EOL> def _on_timeout ( self , index ) : <EOL> if self . _counters [ index ] > <NUM_LIT:1> : <EOL> self . _doubles [ index ] ( ) <EOL> else : <EOL> self . _singles [ index ] ( ) <EOL> self . _counters [ index ] = <NUM_LIT:0> <EOL> def click ( self , button ) : <EOL> if button == Qt . LeftButton : <EOL> self . _counters [ <NUM_LIT:0> ] += <NUM_LIT:1> <EOL> if not self . l_timer . isActive ( ) : <EOL> self . l_timer . start ( ) <EOL> if button == Qt . RightButton : <EOL> self . _counters [ <NUM_LIT:1> ] += <NUM_LIT:1> <EOL> if not self . r_timer . isActive ( ) : <EOL> self . r_timer . start ( ) </s>
