Python 3.x 如何使绘图划线日期选择器范围和按钮工作
我正在使用Python 3.x 如何使绘图划线日期选择器范围和按钮工作,python-3.x,plotly,Python 3.x,Plotly,我正在使用DashbyPlotly创建一个仪表板,但它将日期范围作为输入。但我在尝试模仿中所示的简单示例时,遇到了TypeError。我不明白我做错了什么。下面是我的代码: import dash import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output, State from datetime import datetime
Dash
byPlotly
创建一个仪表板,但它将日期范围作为输入。但我在尝试模仿中所示的简单示例时,遇到了TypeError
。我不明白我做错了什么。下面是我的代码:
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
from datetime import datetime as dt
app = dash.Dash(__name__)
app.config['suppress_callback_exceptions'] = True
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
app.layout = html.Div(children=[
html.H1(children='AE Analytics Dashboard', style={'color': 'gray', 'text-align': 'center'}),
html.Div(
html.Div(
dcc.Input(id='input-box', placeholder='Enter AE Name', type='text',value=''),
dcc.DatePickerRange(
id='date-picker-range',
start_date_placeholder_text= 'Select a date!',
end_date_placeholder_text='Select a date!'
)
),
html.Button('Submit', id='button'),
# html.Div(id='output-container-button', children='Enter a value and press submit')
)
])
if __name__ == "__main__":
app.run_server(debug=True)
错误:
TypeError:不可损坏的类型:“DatePickerage”
尝试使用html.Button
时出现以下错误:
类型错误:不支持的格式字符串传递到按钮。格式
我解决了。这是一个愚蠢的错误。下面是更正后的代码,供任何人参考
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
from datetime import datetime as dt
app = dash.Dash(__name__)
app.config['suppress_callback_exceptions'] = True
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
app.layout = html.Div(children=[
html.H1(children='AE Analytics Dashboard', style={'color': 'gray', 'text-align': 'center'}),
html.Div(
html.Div([
dcc.Input(id='input-1-state', type='text', placeholder='AE Name', style={'text-align': 'center'}, value=''),
dcc.DatePickerRange(
id='date-picker-range',
start_date_placeholder_text= 'Select a date!',
end_date_placeholder_text='Select a date!'
),
html.Button(id='submit-button', n_clicks=0, children='Submit')
]),
),
])
if __name__ == "__main__":
app.run_server(debug=True)
我解决了。这是一个愚蠢的错误。下面是更正后的代码,供任何人参考
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
from datetime import datetime as dt
app = dash.Dash(__name__)
app.config['suppress_callback_exceptions'] = True
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
app.layout = html.Div(children=[
html.H1(children='AE Analytics Dashboard', style={'color': 'gray', 'text-align': 'center'}),
html.Div(
html.Div([
dcc.Input(id='input-1-state', type='text', placeholder='AE Name', style={'text-align': 'center'}, value=''),
dcc.DatePickerRange(
id='date-picker-range',
start_date_placeholder_text= 'Select a date!',
end_date_placeholder_text='Select a date!'
),
html.Button(id='submit-button', n_clicks=0, children='Submit')
]),
),
])
if __name__ == "__main__":
app.run_server(debug=True)
你能解释一下吗?我遇到了类似的错误,我无法理解仅仅是看你的代码。无论你想在一个特定的
Div
中使用什么组件,你都必须将它们像列表一样包装在一个iterable中。比较问题和答案之间的html.Div
下面的html.H1
,让我知道你是否能找出差异。你能解释一下吗?我遇到了类似的错误,我无法理解仅仅是看你的代码。无论你想在一个特定的Div
中使用什么组件,你都必须将它们像列表一样包装在一个iterable中。比较问题和答案之间的html.Div
下面的html.H1
,并告诉我您是否能找出差异。