✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Barcode Scanner wiht EAN into dbc.Input

Hi I would like to know how to clear dbc.Input after enter event.
I try to build barcode scanner to read EAN into a Input.

Steps:
1-Read ean barcode
2-Send this EAN to a Div (this need receive multiples barcodes).
3-cleanup dbc.Input

This is possible using Dash?

import dash
import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State

import pandas as pd

#app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
app = dash.Dash(__name__)

app.layout = html.Div([
    dbc.Row(dbc.Col(html.H3("Maturação de Gelo"),
        width={'size':6, 'offset':3},
        ),
    ),
    dbc.Row(dbc.Col(html.Div([
        dbc.Input(id='input', type='text'),
        html.Br(),
        html.P(id="output"),
        ]),width={'size':6, 'offset':3}
      )
    )
])


@app.callback(
    Output("output", "children"), 
    [Input("input", "n_submit")],
    [State('input', 'value')])
def output_text(n_submit, value):


    return value
    

if __name__ == '__main__':
    app.run_server(debug=True)

Hi everyone
Any help? Please.

Hi @zinho

Try using the dcc.Input as Output of the callback and send a “” to it:

@app.callback(
    Output("output", "children"), 
    Output('input', 'value'),
    [Input("input", "n_submit")],
    [State('input', 'value')])
def output_text(n_submit, value):


    return value, ""
1 Like

Hi Eduardo

This solve my problem, now I wiil lear how to add into a Dash_table element.
Thank you!