-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic_info_widget.py
35 lines (25 loc) · 1.02 KB
/
basic_info_widget.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
import ipywidgets as widgets
class BasicInfoWidget():
'''Widget used to display basic user information
'''
def __init__(self):
'''Constructor Method for the basic info widget.
'''
self.html = """\
<p><b>Username:</b> {}<p>
<p><b>Number of Messages:</b> {}<p>
<p><b>Message Samples:</b> <br>{}<p>
"""
self.widget = widgets.HTML(self.html.format("", "", ""))
def get_widget(self):
'''Obtain underlying widget object
:return: Widget containing basic user information.
:rtype: ipywidgets.HTML
'''
return self.widget
def init_widget_data(self, user_info):
'''Initialize Widget
:param user_info: Dictionary containing messages for each user.
:type user_info: dict
'''
self.widget.value = self.html.format(user_info["user_name"], len(user_info["user_messages"]), "<br>".join(user_info["user_messages"][:10]))