예제 #1
0
파일: chats.py 프로젝트: GMati13/chat
def append_message(message, chat_type):
    is_me = message['outgoing'] or store.get_item(
        'me')['id'] == message['from_user']['id']
    if chat_type == 'private':
        body.history.append_child(
            urwid.AttrMap(urwid.Message(message),
                          theme.green_light if is_me else theme.main_light,
                          theme.green_dark if is_me else theme.main_dark))
    elif chat_type in ['group', 'channel']:
        body.history.append_child(
            urwid.AttrMap(urwid.Message(message), theme.main_light,
                          theme.main_dark))
예제 #2
0
파일: chats.py 프로젝트: GMati13/chat
def get_dialogs():
    header.Header.left_column.set_text(status_line.header_loading)
    body.history.clear()
    dialogs = client.get_dialogs()
    store.set_item('dialogs', dialogs)
    show_dialog_info(0)
    for dialog in dialogs['dialogs']:
        if dialog['chat']['type'] in ['private', 'group', 'channel']:
            body.history.append_child(
                urwid.AttrMap(urwid.Dialog(dialog), theme.main_light,
                              theme.main_dark))
        else:
            body.history.append_child(
                urwid.Text(status_line.info_unsupported_channel))

    header.Header.left_column.set_text(
        status_line.header_dialogs.format(total_count=dialogs['total_count']))
    app.mode.toggle_mode('DIALOGS')
예제 #3
0
import lib.urwid as urwid
import theme

contacts = urwid.List()
history = urwid.List()

Body = urwid.Columns([
    urwid.AttrMap(history, theme.main_light)
], dividechars=1, min_width=1)
예제 #4
0
import lib.urwid as urwid
import theme
from lib.ui.header import Header
from lib.ui.body import Body
from lib.ui.footer import Footer

Document = urwid.Frame(header=urwid.AttrMap(Header, theme.main_dark),
                       body=urwid.AttrMap(Body, theme.main_dark),
                       footer=urwid.AttrMap(Footer, theme.main_dark),
                       focus_part='footer')
예제 #5
0
파일: footer.py 프로젝트: GMati13/chat
import lib.urwid as urwid
import theme

message_line = urwid.EditText()
status_line = urwid.StatusLine()
command_line = urwid.EditText()
info_line = urwid.StatusLine()

tools = urwid.ListBox([
    urwid.AttrMap(message_line, theme.main_dark, theme.main_light),
    urwid.AttrMap(status_line, theme.main_dark),
    urwid.AttrMap(command_line, theme.main_dark, theme.main_light)
])

Footer = urwid.BoxAdapter(
    urwid.ListBox([
        urwid.AttrMap(info_line, theme.main_dark),
        urwid.BoxAdapter(tools, 3)
    ]), 4)