# -*- python -*- from common import * class MyIRC(Entry): def __init__(self, *args, ii = None, **kwargs): self.semaphore = threading.Semaphore() self.text = 'Irc: 0' self.count = 0 self.ii = ii Entry.__init__(self, *args, **kwargs) def colourise(self, n): if n >= 1: return '32' if n >= 5: return '33' if n >= 10: return '31' return '39' def adjust(self, n): self.semaphore.acquire() try: self.count += n if self.count < 0: self.count = 0 self.text = 'Irc: \033[%sm%i\033[0m' % (self.colourise(self.count), self.count) finally: self.semaphore.release() self.invalidate() def action(self, col, button, x, y): if self.count == 0: return if button == LEFT_BUTTON: G.groupi = 1 G.group = G.groups[G.groupi] self.ii.action(0, RIGHT_BUTTON, 0, 0) def function(self): return self.text