FileDownload widget does not disable/enable correctly

panel==0.9.7

I would like to enable and disable FileDownload button, however it seems not to refresh. See example below.

Code:

import panel as pn
pn.extension()

b = pn.widgets.Button(name='Button', disabled=True)
db = pn.widgets.FileDownload(label='File download', disabled=True)
pn.Row(b, db)


b.disabled = False
db.disabled = False


pn.Row(b, db)

Sure looks like a bug! Depending on your requirements, the following may be a suitable workaround for the time being:

import panel as pn
from io import StringIO
from bokeh.sampledata.autompg import autompg
pn.extension()

async_event = pn.widgets.Button(name='<some async event>', button_type='primary')
layout = None

def filtered_file():
    sio = StringIO()
    autompg.to_csv(sio)
    sio.seek(0)
    return sio

def db_cb(event=None):
    disabled = async_event.clicks % 2 == 0
    b.disabled = disabled
    db.disabled = disabled
    if isinstance(layout, pn.Row):
        layout[2] = db.clone()
    return db

async_event.on_click(db_cb)
b = pn.widgets.Button(name='Button')
db = pn.widgets.FileDownload(callback=filtered_file, label='File download', filename='filtered_autompg.csv')
layout = pn.Row(async_event, b, db_cb)
layout

Thank you! This did the job for me.

I noticed a related issue was reported on github so I added a comment and a reference to this thread there.

thanks for the post. I was already convinced that my issue would be forever forgotten…