question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

widgets.Button for handling download

See original GitHub issue

Hi, I would like to create a download button from widgets.Button, is it possible to do that? I know that the download can be achieved using link tag, i.e.

<a href="link/to/file" download>test_download</a>

Using button, I am not sure what to put to handle the download of the temporary file I created.

...
def on_button_download_clicked(b):
    # TODO: Handle download 

    # Disable button after downloading
    btn_download.disabled = True

btn_download.on_click(on_button_download_clicked)
...

Cheers

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
nick-bradycommented, Feb 1, 2020

I found this thread trying to do exactly what @marketneutral said. I had the same thought that it must be a very easy/standard thing. I had issues when trying to use even an anchor within the notebook. It was getting Forbidden errors. I found something called FileLink.

Quick example:

from IPython.display import display, FileLink

local_file = FileLink('./demo.xlsx', result_html_prefix="Click here to download: ")
display(local_file)

I did some more searching and found this StackOverflow post. I added my answer (based on comments) if anyone else needs.

4reactions
marketneutralcommented, Aug 13, 2019

Yes, I think you are right – it’s a duplicate. #2445 is closed but I admit that I don’t readily follow that accepted answer. I can’t seem to find anything anywhere that gives an example of basic and core button functionality:

  1. How do I have an ipywidgets button that when clicked, follows a link to another webpage?
  2. How do you have an ipywidgets button send a file to the browser?
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to download a file using ipywidget button? - Stack Overflow
The most elegant way I've seen is Solution 1 here (slightly modified and presented below): from ipywidgets import HTML from IPython.display ...
Read more >
How to Create a File Download Button in Elementor - YouTube
The files can be downloaded easily by your website visitors, with one click, onto a computer or ... Related Links: Button Widget tutorial ......
Read more >
Create a download button - Flutter documentation
Create a download button · Define a new stateless widget · Define the button's possible visual states · Display the button shape ·...
Read more >
JetElements: How to Use Download Button Widget - Crocoblock
The Download Button widget of JetElements will come in handy if you want your visitors to download files of any type. With it,...
Read more >
Widget Events — Jupyter Widgets 7.7.0 documentation
The Button is not used to represent a data type. Instead the button widget is used to handle mouse clicks. The on_click method...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found