1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# -*- 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
|