python dash输入带有for循环,并通过将行,列和矩阵的数量作为参数发送
我想通过将行,列和矩阵作为参数发送的数量来创建一个带有for循环的输入。我写的是下面的代码。我在哪里做错了(我想创建图片中的输入框)
matris_toplam = html.Div([
html.Div(
[html.Hr(),
html.Label('Matrix Row Number'),
html.Br(),
dcc.Input(id='msatir', type='number',
style={'textAlign': 'center', 'width': 'auto'}),
html.A(' [ ? ]', title='Toplanacak Matrislerin Satır Sayısı', href=''),
html.Br(),
html.Label('Matrix Column Sayısı'),
html.Br(),
dcc.Input(id='msutun', type='number',
style={'textAlign': 'center', 'width': 'auto'}),
html.A(' [ ? ]', title='Toplanacak Matrislerin Sütun Sayısı', href=''),
html.Br(),
html.Label('Matrix Number'),
html.Br(),
dcc.Input(id='msayi', type='number',
style={'textAlign': 'center', 'width': 'auto'}),
html.A(' [ ? ]', title='Toplanacak Matrislerin Sayısı', href=''),
html.Br(),
],
className='mt-2 ml-2',
),
])
def matrixbox(row,col,sayi):
b=row*col*sayi
return [dcc.Input(type='text', id='input%i' % i)for i in range(b)]
@app.callback(
[dash.dependencies.Output('input%i' %i, 'children')for i in range(row*col*sayi)],
[Input("msatir", "value"),Input("msutun", "value"),Input("msayi", "value")],
)
def update_output(row,col,sayi):
if row != None and col != None and sayi != None:
a=matrixbox(row,col,sayi)
return '{}'.format(a)
I want to create an input with a for loop by sending the number of rows, columns and matrices as parameters.I write is the code below.Where am i doing wrong (I want to create input boxes like in the picture)
matris_toplam = html.Div([
html.Div(
[html.Hr(),
html.Label('Matrix Row Number'),
html.Br(),
dcc.Input(id='msatir', type='number',
style={'textAlign': 'center', 'width': 'auto'}),
html.A(' [ ? ]', title='Toplanacak Matrislerin Satır Sayısı', href=''),
html.Br(),
html.Label('Matrix Column Sayısı'),
html.Br(),
dcc.Input(id='msutun', type='number',
style={'textAlign': 'center', 'width': 'auto'}),
html.A(' [ ? ]', title='Toplanacak Matrislerin Sütun Sayısı', href=''),
html.Br(),
html.Label('Matrix Number'),
html.Br(),
dcc.Input(id='msayi', type='number',
style={'textAlign': 'center', 'width': 'auto'}),
html.A(' [ ? ]', title='Toplanacak Matrislerin Sayısı', href=''),
html.Br(),
],
className='mt-2 ml-2',
),
])
def matrixbox(row,col,sayi):
b=row*col*sayi
return [dcc.Input(type='text', id='input%i' % i)for i in range(b)]
@app.callback(
[dash.dependencies.Output('input%i' %i, 'children')for i in range(row*col*sayi)],
[Input("msatir", "value"),Input("msutun", "value"),Input("msayi", "value")],
)
def update_output(row,col,sayi):
if row != None and col != None and sayi != None:
a=matrixbox(row,col,sayi)
return '{}'.format(a)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会让您的样式:)。这应该起作用。
I will let the styling for you :). This should work.