Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

File upload widget not working inside loop #457

Open
mr-easy opened this issue Jul 10, 2024 · 2 comments
Open

File upload widget not working inside loop #457

mr-easy opened this issue Jul 10, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@mr-easy
Copy link

mr-easy commented Jul 10, 2024

I want to create multiple File upload widget, but it's creating just one widget when created inside a loop.

files = []
for i in range(4):
    files.append(mr.File(label="File upload "+str(i+1), max_file_size="100MB"))

This gives only one file widget 'File upload 4'

While this works:

files = []
files.append(mr.File(label="File upload "+str(1), max_file_size="100MB"))
files.append(mr.File(label="File upload "+str(2), max_file_size="100MB"))
files.append(mr.File(label="File upload "+str(3), max_file_size="100MB"))
files.append(mr.File(label="File upload "+str(4), max_file_size="100MB"))

But I want to do it in a loop.

@pplonski
Copy link
Contributor

Hi @mr-easy,

Looks like we don't support creating file upload widgets in the loop, sorry. Here is docs for File widget https://runmercury.com/docs/input-widgets/file/ The File widget is missing url_key argument in constructor. Other widgets with url_key can be created in the loop https://runmercury.com/examples/create-widgets-in-loop/ I believe this can be fixed.

How many widgets would you like to create in the loop? What is your use case?

@pplonski pplonski added the bug Something isn't working label Jul 10, 2024
@pplonski pplonski changed the title Fiel upload widget not working inside loop Fileupload widget not working inside loop Jul 10, 2024
@mr-easy
Copy link
Author

mr-easy commented Jul 10, 2024

I am creating a dashboard for stock market trade analysis. Now I want to give user the option to upload multiple files along with a multiplier for each file. So first I ask how many files needs to be uploaded, and then that many Fileupload widgets are created. Can range from 1 to 10.

@pplonski pplonski changed the title Fileupload widget not working inside loop File upload widget not working inside loop Jul 10, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants