Closed gtdang closed 2 months ago
@ntolley I wonder if you have pictured how this looks from the GUI side. ipywidgets (that a I know) doesn't have a folder selector widget. I've been looking on creating a custom widget but it looks a bit more complicated that I initially thought.
Honestly I assumed there would be one already built in. This project seems to achieve what we want, but it's not great to add a uncommonly used/supported dependency for just one function.
Alternatively could the FileUpload
class source code by recycled for folder selection? I'll admit reading this it's a bit unclear if this is actually possible...
Why do you need a folder selector widget? To export multiple trials?
Try this:
from ipywidgets import HTML
from IPython.display import display
import base64
res = 'computed results'
#FILE
filename = 'res.txt'
b64 = base64.b64encode(res.encode())
payload = b64.decode()
#BUTTONS
html_buttons = '''<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<a download="{filename}" href="data:text/csv;base64,{payload}" download>
<button class="p-Widget jupyter-widgets jupyter-button widget-button mod-warning">Download File</button>
</a>
</body>
</html>
'''
html_button = html_buttons.format(payload=payload,filename=filename)
display(HTML(html_button))
probably what you're looking for
@jasmainak Awesome! Thanks, you saved me a lot of time!
Add a button to export simulations to a csv file
Related to #709