-
Notifications
You must be signed in to change notification settings - Fork 0
/
frdls.py
61 lines (56 loc) · 1.81 KB
/
frdls.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
# coding=UTF-8
'''
@Author: cenmmy
@LastEditors: cenmmy
@Description: friend list
@Date: 2019-04-14 11:24:24
@LastEditTime: 2019-04-19 16:02:05
'''
import curses
from pad import ScrollablePad
"""
classname: FrdLs
description: friend list
"""
class FrdLs(ScrollablePad):
'''
@description: Initialization function of the FrdLs
@param {stdscr: standard screen,
ncols: list's width,
sminrow: display area upper left y,
smincol: dispaly area upper left x,
smaxrow: display area lower right y,
smaxcol: display area lower right x,
friends: friends,
fgcolor: foreground color,
bgcolor: background color}
@return: void
'''
def __init__(self, stdscr, ncols, sminrow, smincol, smaxrow, smaxcol, friends, fgcolor=curses.COLOR_WHITE, bgcolor=curses.COLOR_BLACK, color_pair=1):
ScrollablePad.__init__(self, stdscr, len(friends) + 1, ncols, sminrow, smincol, smaxrow, smaxcol, fgcolor, bgcolor, color_pair)
self.title = ['FRIEND LIST']
self._friends = friends
'''
@description: draw content in the pad
@param {void}
@return: void
'''
def content(self):
content = self.title + self.friends
# If the size of pad changes, reset the size of pad
if self.nlines != len(content):
self.resize_pad(len(content), self.ncols)
# draw friend list
try:
for index, item in enumerate(content):
self.pad.addstr(index, 0, item)
self.pad.chgat(index, 0, -1, curses.color_pair(self.color_pair))
except curses.error:
pass
@property
def friends(self):
return self._friends
@friends.setter
def friends(self, value):
self._friends = value