def __init__(self, delegate):
"""
init
"""
self.delegate = delegate
# Create the components of the frame:
# * The title and the clock in the header
titleBar = TitleBar(("titleBar", "ChatMaster 3000"), align="center")
clock = urwid.AttrMap(Clock(self.delegate, align="right"), "titleBar")
# The actual title bar. The title has a relative width, while clock has a set width of 5 columns wide.
self.titleBar = ColumnView([('weight', 1, titleBar), (5, clock)])
self.chatLog = ChatWindow()
self.chatBox = ChatBox("> ", self)
# Create the channel list and set its label
self.channelList = ChannelList()
self.channelList.body.insert(0, urwid.Text(("channelList-text-bold", "Channels:")))
# Wrap them with a display attribute. This will enable color application.
header = self.titleBar.wrapWithAttribute("titleBar")
footer = self.chatBox.wrapWithAttribute("footer")
chatLog = self.chatLog.wrapWithAttribute("body")
channelList = self.channelList.wrapWithAttribute("channelList")
# Create a border between the channel list and the chat log
channelListWithPadding = urwid.Padding(channelList, align="left", width=("relative", 95))
channelListWithPadding = urwid.AttrMap(channelListWithPadding, "border")
# Put them both in a columns widget
self.columnView = ColumnView([(15, channelListWithPadding), ('weight', 1, chatLog)])
# Call the super class and let it handle the heavy lifting.
super(ChatFrame, self).__init__(self.columnView, header=header, footer=footer, focus_part='footer')
评论列表
文章目录