daq.NumericInput( min=0, max=10, value=4, id='darktheme-daq-numericinput', className='dark-theme-control' ), html.Br(), daq.PowerButton( on=True, color=theme['primary'], id='darktheme-daq-powerbutton', className='dark-theme-control' ), html.Br(), daq.PrecisionInput( precision=4, value=299792458, id='darktheme-daq-precisioninput', className='dark-theme-control' ), html.Br(), daq.StopButton( id='darktheme-daq-stopbutton', className='dark-theme-control' ), html.Br(), daq.Slider( min=0, max=100, value=30, targets = {"25": {"label": "TARGET"}}, color=theme['primary'], id='darktheme-daq-slider', className='dark-theme-control' ), html.Br(),
), daq.BooleanSwitch( id='term-switch', label='REAR', on=True, disabled=False, ), ]), html.Div( className='column right', children=[ daq.PrecisionInput( id='value-input', label='Current input is 0.00 mA', precision=4, min=-10, max=50, value=0.000E0, size=100, ), html.Br(), html.P("Voltage (V)"), daq.LEDDisplay( id='my-current-V', # label = "Voltage (V)", # labelPosition = 'top', value=f'{0.00:05.2f}', color="#FF5E5E", size=40), html.Br(), html.P("Current (mA)"),
def generate_main_layout( theme='light', src_type='V', mode_val='single', fig=None, sourcemeter=iv_generator ): """generate the layout of the app""" source_label, measure_label = get_source_labels(src_type) source_unit, measure_unit = get_source_units(src_type) source_max = get_source_max(src_type) if mode_val == 'single': single_style = { 'display': 'flex', 'flex-direction': 'column', 'alignItems': 'center' } sweep_style = {'display': 'none'} label_btn = 'Single measure' else: single_style = {'display': 'none'} sweep_style = { 'display': 'flex', 'flex-direction': 'column', 'alignItems': 'center' } label_btn = 'Start sweep' # As the trigger-measure btn will have its n_clicks reset by the reloading # of the layout we need to reset this one as well local_vars.reset_n_clicks() # Doesn't clear the data of the graph if fig is None: data = [] else: data = fig['data'] html_layout = [ html.Div( className='row', children=[ # graph to trace out the result(s) of the measurement(s) html.Div( id='IV_graph_div', className="eight columns", children=[ dcc.Graph( id='IV_graph', figure={ 'data': data, 'layout': dict( paper_bgcolor=bkg_color[theme], plot_bgcolor=bkg_color[theme], font=dict( color=text_color[theme], size=15, ), xaxis={ 'color': grid_color[theme], 'gridcolor': grid_color[theme] }, yaxis={ 'color': grid_color[theme], 'gridcolor': grid_color[theme] } ) } ) ] ), # controls and options for the IV tracer html.Div( className="two columns", id='IV-options_div', children=[ html.H4( 'Sourcing', title='Choose whether you want to source voltage ' 'and measure current or source current and ' 'measure voltage' ), dcc.RadioItems( id='source-choice', options=[ {'label': 'Voltage', 'value': 'V'}, {'label': 'Current', 'value': 'I'} ], value=src_type ), html.Br(), html.H4( 'Measure mode', title='Choose if you want to do single measurement' ' or to start a sweep' ), dcc.RadioItems( id='mode-choice', options=[ {'label': 'Single measure', 'value': 'single'}, {'label': 'Sweep', 'value': 'sweep'} ], value=mode_val ), html.Br(), html.Div( daq.StopButton( id='clear-graph_btn', buttonText='Clear graph', size=150 ), style={ 'alignItems': 'center', 'display': 'flex', 'flex-direction': 'row' } ), html.Br(), daq.Indicator( id='clear-graph_ind', value=False, style={'display': 'none'} ) ] ), # controls for the connexion to the instrument html.Div( id='instr_controls', children=[ html.H4( sourcemeter.instr_user_name, ), # A button to turn the instrument on or off html.Div( children=[ html.Div( id='power_button_div', children=daq.PowerButton( id='power_button', on='false' ) ), html.Br(), html.Div( children=daq.Indicator( id='mock_indicator', value=sourcemeter.mock_mode, label='is mock?' ), style={'margin': '20px'}, title='If the indicator is on, it means ' 'the instrument is in mock mode' ) ], style=h_style ), # An input to choose the COM/GPIB port dcc.Input( id='instr_port_input', placeholder='Enter port name...', type='text', value='' ), html.Br(), # A button which will initiate the connexion daq.StopButton( id='instr_port_button', buttonText='Connect', disabled=True ), html.Br(), html.Div( id='instr_status_div', children="", style={'margin': '10 px'} ) ], style={ 'display': 'flex', 'flex-direction': 'column', 'alignItems': 'center', 'justifyContent': 'space-between', 'border': '2px solid #C8D4E3', 'background': '#f2f5fa' } ) ] ), html.Div( id='measure_controls_div', className='row', children=[ # Sourcing controls html.Div( id='source-div', className="three columns", children=[ # To perform single measures adjusting the source with # a knob html.Div( id='single_div', children=[ daq.Knob( id='source-knob', value=0.00, min=0, max=source_max, label='%s (%s)' % ( source_label, source_unit ) ), daq.LEDDisplay( id="source-knob-display", label='Knob readout', value=0.00 ) ], style=single_style ), # To perfom automatic sweeps of the source html.Div( id='sweep_div', children=[ html.Div( id='sweep-title', children=html.H4( "%s sweep:" % source_label ) ), html.Div( [ 'Start', html.Br(), daq.PrecisionInput( id='sweep-start', precision=4, min=0, max=source_max, label=' %s' % source_unit, labelPosition='right', value=1, style={'margin': '5px'} ), ], title='The lowest value of the sweep', style=h_style ), html.Div( [ 'Stop', daq.PrecisionInput( id='sweep-stop', precision=4, min=0, max=source_max, label=' %s' % source_unit, labelPosition='right', value=9, style={'margin': '5px'} ) ], title='The highest value of the sweep', style=h_style ), html.Div( [ 'Step', daq.PrecisionInput( id='sweep-step', precision=4, min=0, max=source_max, label=' %s' % source_unit, labelPosition='right', value=source_max / 20., style={'margin': '5px'} ) ], title='The increment of the sweep', style=h_style ), html.Div( [ 'Time of a step', daq.NumericInput( id='sweep-dt', value=0.5, min=0.1, style={'margin': '5px'} ), 's' ], title='The time spent on each increment', style=h_style ), html.Div( [ daq.Indicator( id='sweep-status', label='Sweep active', value=False ) ], title='Indicates if the sweep is running', style=h_style ) ], style=sweep_style ) ] ), # measure button and indicator html.Div( id='trigger_div', className="two columns", children=[ daq.StopButton( id='trigger-measure_btn', buttonText=label_btn, size=150 ), daq.Indicator( id='measure-triggered', value=False, label='Measure active' ), ] ), # Display the sourced and measured values html.Div( id='measure_div', className="five columns", children=[ daq.LEDDisplay( id="source-display", label='Applied %s (%s)' % ( source_label, source_unit ), value="0.0000" ), daq.LEDDisplay( id="measure-display", label='Measured %s (%s)' % ( measure_label, measure_unit ), value="0.0000" ) ] ) ], style={ 'width': '100%', 'flexDirection': 'column', 'alignItems': 'center', 'justifyContent': 'space-between' } ), html.Div( children=[ html.Div( children=dcc.Markdown(''' **What is this app about?** This is an app to show the graphic elements of Dash DAQ used to create an interface for an IV curve tracer using a Keithley 2400 SourceMeter. This mock demo does not actually connect to a physical instrument the values displayed are generated from an IV curve model for demonstration purposes. **How to use the app** First choose if you want to source (apply) current or voltage, using the radio item located on the right of the graph area. Then choose if you want to operate in a single measurement mode or in a sweep mode. ***Single measurement mode*** Adjust the value of the source with the knob at the bottom of the graph area and click on the `SINGLE MEASURE` button, the measured value will be displayed. Repetition of this procedure for different source values will reveal the full IV curve. ***Sweep mode*** Set the sweep parameters `start`, `stop` and `step` as well as the time spent on each step, then click on the button `START SWEEP`, the result of the sweep will be displayed on the graph. The data is never erased unless the button `CLEAR GRAPH is pressed` or if the source type is changed. You can purchase the Dash DAQ components at [ dashdaq.io](https://www.dashdaq.io/) '''), style={ 'max-width': '600px', 'margin': '15px auto 300 px auto', 'padding': '40px', 'alignItems': 'left', 'box-shadow': '10px 10px 5px rgba(0, 0, 0, 0.2)', 'border': '1px solid #DFE8F3', 'color': text_color[theme], 'background': bkg_color[theme] } ) ] ) ] if theme == 'dark': return daq.DarkThemeProvider(children=html_layout) elif theme == 'light': return html_layout
PrecisionInput = html.Div(children=[ html.H1('Precision Input Examples and Reference'), html.Hr(), html.H3('Default Precision Input'), reusable_components.Markdown("An example of a default precision input without \ any extra properties."), reusable_components.Markdown( examples['precision-input'][0], style=styles.code_container ), html.Div( examples['precision-input'][1], className='example-container', style={'overflow-x': 'initial'} ), html.Hr(), html.H3('Label'), reusable_components.Markdown("Set the label and label position with `label` and `labelPosition`."), ComponentBlock('''import dash_daq as daq daq.PrecisionInput( label='Label', labelPosition='top', precision=2, value=12 )''', style=styles.code_container), html.Hr(), html.H3('Precision'), reusable_components.Markdown("The `precision` property is mandatory for this component. The `precision` property \ indicates the accuracy of the specified number."), ComponentBlock('''import dash_daq as daq daq.PrecisionInput( precision=2, value=125 )''', style=styles.code_container), html.Hr(), html.H3('Max and Min'), reusable_components.Markdown("Set the maximum and minimum value of the numeric input with `max` and `min`."), ComponentBlock('''import dash_daq as daq daq.PrecisionInput( precision=2, value=15, max=20, min=10 )''', style=styles.code_container), html.Hr(), html.H3('Size'), reusable_components.Markdown("Set the length (in pixels) of the numeric input `size`."), ComponentBlock('''import dash_daq as daq daq.PrecisionInput( size=120, precision=4, value=245 )''', style=styles.code_container), html.Hr(), html.H3('Disabled'), reusable_components.Markdown("Disable the precision input by setting `disabled=True`."), ComponentBlock('''import dash_daq as daq daq.PrecisionInput( disabled=True, precision=4, value=9999 )''', style=styles.code_container), html.Hr(), html.H3("Precision Input Properties"), generate_prop_info('PrecisionInput', lib=daq) ])
[ daq.BooleanSwitch(id="plot-switch", color="#565656", on=False) ], title="Controls whether to plot", ), ], className="control plot", ), html.Div( [ html.Div([html.Label("Diffusion")]), html.Div( [ daq.PrecisionInput( id='diffusion', precision=2, value=1e-12) ], title="Adjust NP diffusion", ), ], className="diffusion input", ), html.Div( [ html.Div([html.Label("binding")]), html.Div( [ daq.PrecisionInput( id='binding', precision=2, value=1e4) ], title="Adjust NP binding strength",
def generate_main_layout(theme="light", src_type="V", mode_val="single", fig=None, sourcemeter=iv_generator): """generate the layout of the app""" source_label, measure_label = get_source_labels(src_type) source_unit, measure_unit = get_source_units(src_type) source_max = get_source_max(src_type) if mode_val == "single": single_style = { "display": "flex", "flex-direction": "column", "alignItems": "center", } sweep_style = {"display": "none"} label_btn = "Single measure" else: single_style = {"display": "none"} sweep_style = { "display": "flex", "flex-direction": "column", "alignItems": "center", } label_btn = "Start sweep" # As the trigger-measure btn will have its n_clicks reset by the reloading # of the layout we need to reset this one as well local_vars.reset_n_clicks() # Doesn't clear the data of the graph if fig is None: data = [] else: data = fig["data"] html_layout = [ html.Div( className="row", children=[ # graph to trace out the result(s) of the measurement(s) html.Div( id="IV_graph_div", className="eight columns", style={"margin": "20px"}, children=[ dcc.Graph( id="IV_graph", figure={ "data": data, "layout": dict( paper_bgcolor=bkg_color[theme], plot_bgcolor=bkg_color[theme], font=dict(color=text_color[theme], size=15), xaxis={ "color": grid_color[theme], "gridcolor": grid_color[theme], }, yaxis={ "color": grid_color[theme], "gridcolor": grid_color[theme], }, ), }, ) ], ), # controls for the connexion to the instrument html.Div( id="instr_controls", className="two columns", children=[ html.H4(sourcemeter.instr_user_name), # A button to turn the instrument on or off html.Div( children=[ html.Div( id="power_button_div", children=daq.PowerButton(id="power_button", on="false"), ), html.Br(), html.Div( children=daq.Indicator( id="mock_indicator", value=sourcemeter.mock_mode, label="is mock?", ), style={"margin": "20px"}, title="If the indicator is on, it means " "the instrument is in mock mode", ), ], style=h_style, ), # An input to choose the COM/GPIB port dcc.Input( id="instr_port_input", placeholder="Enter port name...", type="text", value="", ), html.Br(), # A button which will initiate the connexion daq.StopButton(id="instr_port_button", buttonText="Connect", disabled=True), html.Br(), html.Div( id="instr_status_div", children="", style={"margin": "10 px"}, ), ], style={ "margin": "50px", "display": "flex", "flex-direction": "column", "alignItems": "center", "justifyContent": "space-between", "border": "2px solid #C8D4E3", "background": "#f2f5fa", }, ), ], ), html.Div( id="measure_controls_div", className="row", children=[ # controls and options for the IV tracer html.Div( className="two columns", id="IV-options_div", children=[ html.H4( "Sourcing", title="Choose whether you want to source voltage " "and measure current or source current and " "measure voltage", ), dcc.RadioItems( id="source-choice", options=[ { "label": "Voltage", "value": "V" }, { "label": "Current", "value": "I" }, ], value=src_type, ), html.Br(), html.H4( "Measure mode", title="Choose if you want to do single measurement" " or to start a sweep", ), dcc.RadioItems( id="mode-choice", options=[ { "label": "Single measure", "value": "single" }, { "label": "Sweep", "value": "sweep" }, ], value=mode_val, ), html.Br(), html.Div( daq.StopButton(id="clear-graph_btn", buttonText="Clear graph", size=150), style={ "alignItems": "center", "display": "flex", "flex-direction": "row", }, ), html.Br(), daq.Indicator(id="clear-graph_ind", value=False, style={"display": "none"}), ], ), # Sourcing controls html.Div( id="source-div", className="three columns", children=[ # To perform single measures adjusting the source with # a knob html.Div( id="single_div", children=[ daq.Knob( id="source-knob", value=0.00, min=0, max=source_max, label="%s (%s)" % (source_label, source_unit), ), daq.LEDDisplay( id="source-knob-display", label="Knob readout", value=0.00, ), ], style=single_style, ), # To perfom automatic sweeps of the source html.Div( id="sweep_div", children=[ html.Div( id="sweep-title", children=html.H4("%s sweep:" % source_label), ), html.Div( [ "Start", html.Br(), daq.PrecisionInput( id="sweep-start", precision=4, min=0, max=source_max, label=" %s" % source_unit, labelPosition="right", value=1, style={"margin": "5px"}, ), ], title="The lowest value of the sweep", style=h_style, ), html.Div( [ "Stop", daq.PrecisionInput( id="sweep-stop", precision=4, min=0, max=source_max, label=" %s" % source_unit, labelPosition="right", value=9, style={"margin": "5px"}, ), ], title="The highest value of the sweep", style=h_style, ), html.Div( [ "Step", daq.PrecisionInput( id="sweep-step", precision=4, min=0, max=source_max, label=" %s" % source_unit, labelPosition="right", value=source_max / 20.0, style={"margin": "5px"}, ), ], title="The increment of the sweep", style=h_style, ), html.Div( [ "Time of a step", daq.NumericInput( id="sweep-dt", value=0.5, min=0.1, style={"margin": "5px"}, ), "s", ], title="The time spent on each increment", style=h_style, ), html.Div( [ daq.Indicator( id="sweep-status", label="Sweep active", value=False, ) ], title="Indicates if the sweep is running", style=h_style, ), ], style=sweep_style, ), ], ), # measure button and indicator html.Div( id="trigger_div", className="two columns", children=[ daq.StopButton(id="trigger-measure_btn", buttonText=label_btn, size=150), daq.Indicator(id="measure-triggered", value=False, label="Measure active"), ], ), # Display the sourced and measured values html.Div( id="measure_div", className="five columns", children=[ daq.LEDDisplay( id="source-display", label="Applied %s (%s)" % (source_label, source_unit), value="0.0000", ), daq.LEDDisplay( id="measure-display", label="Measured %s (%s)" % (measure_label, measure_unit), value="0.0000", ), ], ), ], style={ # "width": "100%", "flexDirection": "column", "alignItems": "center", "justifyContent": "space-between", }, ), html.Div(children=[ html.Div( children=dcc.Markdown(""" **What is this app about?** This is an app to show the graphic elements of Dash DAQ used to create an interface for an IV curve tracer using a Keithley 2400 SourceMeter. This mock demo does not actually connect to a physical instrument the values displayed are generated from an IV curve model for demonstration purposes. **How to use the app** First choose if you want to source (apply) current or voltage, using the radio item located on the right of the graph area. Then choose if you want to operate in a single measurement mode or in a sweep mode. ***Single measurement mode*** Adjust the value of the source with the knob at the bottom of the graph area and click on the `SINGLE MEASURE` button, the measured value will be displayed. Repetition of this procedure for different source values will reveal the full IV curve. ***Sweep mode*** Set the sweep parameters `start`, `stop` and `step` as well as the time spent on each step, then click on the button `START SWEEP`, the result of the sweep will be displayed on the graph. The data is never erased unless the button `CLEAR GRAPH is pressed` or if the source type is changed. You can purchase the Dash DAQ components at [ dashdaq.io](https://www.dashdaq.io/) """), style={ "margin": "20px", "padding": "50px", "alignItems": "left", "border": "1px solid #DFE8F3", "color": text_color[theme], "background": bkg_color[theme], }, ) ]), ] if theme == "dark": return daq.DarkThemeProvider(children=html_layout) elif theme == "light": return html_layout
import dash import dash_daq as daq import dash_html_components as html external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = dash.Dash(__name__, external_stylesheets=external_stylesheets) app.layout = html.Div([ daq.PrecisionInput(id='my-precision', label='Default', precision=4, value=1234), html.Div(id='precision-output') ]) @app.callback(dash.dependencies.Output('precision-output', 'children'), [dash.dependencies.Input('my-precision', 'value')]) def update_output(value): return 'The current value is {}.'.format(value) if __name__ == '__main__': app.run_server(debug=True)
import dash import dash_core_components as dcc import dash_html_components as html import dash_daq as daq app = dash.Dash(__name__) app.layout = html.Div([ daq.PrecisionInput(id='my-daq-precisioninput', precision=4, value=299792458) ]) if __name__ == '__main__': app.run_server(debug=True)
def generate_main_layout( theme='light', src_type='Voltage', mode_val='Single measure', fig=None, ): """generate the layout of the app""" source_label, measure_label = get_source_labels(src_type) source_unit, measure_unit = get_source_units(src_type) # As the trigger-measure btn will have its n_clicks reset by the reloading # of the layout we need to reset this one as well local_vars.reset_n_clicks() # Doesn't clear the data of the graph if fig is None: data = [] else: data = fig['data'] html_layout = [ html.Div( id="page-body-content", className='row', children=[ html.Div( id='figure-card', className='six columns', style={'backgroundColor': card_color[theme]}, children= [ html.P("IV Curve"), dcc.Graph( id='IV_graph', style={'width': '100%'}, figure={ 'data': data, 'layout': dict( paper_bgcolor=card_color[theme], plot_bgcolor=card_color[theme], automargin=True, font=dict( color=text_color[theme], size=12, ), xaxis={ 'color': grid_color[theme], 'gridcolor': grid_color[theme] }, yaxis={ 'color': grid_color[theme], 'gridcolor': grid_color[theme] } ) } ) ] ), html.Div( id='control-container', className='five columns', children=[ html.Div( # controls and options for the IV tracer id="up-control-card", style={'backgroundColor': card_color[theme], 'color': text_color[theme]}, children=[ html.Div( id="control-sections", children=[ html.Div( className='IV-source-options', children=[ html.Label("Sourcing", title='Choose whether you want to source voltage ' 'and measure current, or source current and measure voltage'), daq.ToggleSwitch( id='source-choice-toggle', label=['Voltage', 'Current'], style={'width': '150px', 'margin': 'auto'}, value=False ) ], ), html.Div( className='measure-options', children=[ html.Label('Measure mode', title='Choose if you want to do single measurement' ' or to start a sweep mode'), daq.ToggleSwitch( id="mode-choice-toggle", label=['Single measure', 'Sweep'], style={'width': '150px', 'margin': 'auto'}, value=False ) ] )]), daq.StopButton( id='clear-graph_btn', buttonText='Clear Graph', className='daq-button', size=120 ), daq.Indicator( id='clear-graph_ind', color=accent_color[theme], value=False ) ] ), html.Div( id='mid-control-card', style={'backgroundColor': card_color[theme], 'color': text_color[theme], 'marginTop': '10px'}, children=[ # Sourcing controls html.Div( id='source-div', children=[ # To perform single measures adjusting the source with a knob html.Div( id='single_div', style=single_div_toggle_style, children=[ daq.Knob( id='source-knob', size=100, value=0.00, min=0, max=10, color=accent_color[theme], label='%s (%s)' % ( source_label, source_unit ) ), daq.LEDDisplay( id="source-knob-display", label='Knob readout', value=0.00, color=accent_color[theme] ) ] ), # To perform automatic sweeps of the source html.Div( id='sweep_div', style=sweep_div_toggle_style, children=[ html.Div( className='sweep-div-row', children=[ html.Div( className='sweep-div-row', style={'width': '98%'}, children=[ html.Div( id='sweep-title', children=html.P( "%s sweep" % source_label )), html.Div( [ daq.Indicator( id='sweep-status', label='Sweep active', color=accent_color[theme], value=False ) ], title='Indicates if the sweep is running' ) ] ) ] ), html.Div( className='sweep-div-row', children=[ html.Div( className='sweep-div-row-inner', children= [ 'Start', daq.PrecisionInput( id='sweep-start', precision=4, label=' %s' % source_unit, labelPosition='right', value=0, ), ], title='The lowest value of the sweep' ), html.Div( className='sweep-div-row-inner', children=[ 'Stop', daq.PrecisionInput( id='sweep-stop', precision=4, label=' %s' % source_unit, labelPosition='right', value=10 ) ], title='The highest value of the sweep' )]), html.Div( className='sweep-div-row', children=[ html.Div( className='sweep-div-row-inner', children=[ 'Step', daq.PrecisionInput( id='sweep-step', precision=4, label=' %s' % source_unit, labelPosition='right', value=0.2 ) ], title='The increment of the sweep' ), html.Div( className='sweep-div-row-inner', children=[ 'Time of a step', daq.NumericInput( id='sweep-dt', value=0.2, min=0.01, style={'color': text_color[theme]} ), 's' ], title='The time spent on each increment' ) ] ) ] )]), # Measure button and indicator html.Div( id='trigger-div', children=[ daq.StopButton( id='trigger-measure_btn', buttonText='Single measure', className='daq-button', size=120, ), daq.Indicator( id='measure-triggered', color=accent_color[theme], value=False, label='Measure active' ), ] )]), html.Div( id="bottom-card", style={'backgroundColor': card_color[theme], 'color': text_color[theme], 'marginTop': '10px'}, children=[ # Display the sourced and measured values html.Div( id='measure-div', children=[ daq.LEDDisplay( id="source-display", label='Applied %s (%s)' % ( source_label, source_unit ), value=0.00, color=accent_color[theme] ), daq.LEDDisplay( id="measure-display", label='Measured %s (%s)' % ( measure_label, measure_unit ), value=0.0000, color=accent_color[theme] ) ] ) ] ) ] ) ] ) ] if theme == 'dark': return daq.DarkThemeProvider(children=html_layout) if theme == 'light': return html_layout