Выход и очистка предыдущих сообщений в окне чата в dash python - PullRequest
0 голосов
/ 02 ноября 2019

Я создал чат-бота, используя тире. У меня 3 вопроса.

1) Очистить предыдущие сообщения в окне чата после обновления браузера. 2) Выход из приложения, когда я нажимаю на кнопку выхода. 3) Кнопка вызова Когда я нажал на кнопку ввода вместо нажатия кнопки отправки.

Вот код, который я использовал в тире

 html.Table([
                html.Tr([
                    # text input for user message
                    html.Td([dcc.Input(id='msg_input', value='Type your message here', type='text')],
                            style={'valign': 'middle'}),
                    # message to send user message to bot backend
                    html.Td([html.Button('Send', id='send_button',n_clicks=0)],
                            style={'valign': 'middle'}),
                    html.Td([html.Button('Exit', id='exit_button',n_clicks=0)],
                            style={'valign': 'middle',})
                ])
            ])],
            style={'width': '320px', 'margin': '0 auto'}),
        html.Br(),
        html.Div(id='conversation')],
        id='screen',
        style={'width': '320px', 'margin': '0 auto','border':'2px groove powderblue','border-radius': '45px','padding':'15px'
               }
    )
])
@app.callback(
    Output(component_id='conversation', component_property='children'),
    [Input('send_button', 'n_clicks')],
    state=[State(component_id='msg_input', component_property='value')]
)

##### This is for clear input message  every time in input box.

@app.callback(
    Output(component_id='msg_input', component_property='value'),
    [Input(component_id='conversation', component_property='children')]
)
def clear_input(_):
    return ''

...