Skip to content

"binary fragment but received text fragment" error when assigning panel.widgets.Tabulator.value to empty DataFrame in button event #14

@iaipw

Description

@iaipw

What happened:

I'm trying to reset a Tabulator with an empty DataFrame via button event. Nothing happens and there's an error on the browser console output: "binary fragment but received text fragment". This only happens when assigning an emptyDataFrame to the value attribute of a Tabulator in an event. It does not happen if assigning the value attribute with a non-empty DataFrame or if the Tabulator was initialized with an empty DataFrame. Same thing happens if triggered from click event of ButtonIcon.

The attached screenshot shows the button, tabulator table and the error in the browse console output.

Image

How to reproduce

  1. Copy django_embed folder from bokeh-django repo clone to a separate folder
  2. Create virtual environment
  3. Add requirements.txt and pip install -r requirements.txt
# requirements.txt
Django==5.1.6
panel==1.6.1
bokeh==3.6.3
channels[daphne]==4.2.0
bokeh-django @ git+https://github.com/bokeh/bokeh-django@v0.2.0
bokeh_sampledata

  1. In the django_embed/django_embed/shape_viewer.py file, make the following changes to the "panel" method, starting at line 69:
    def panel(self):
        expand_layout = pn.Column()

        # --------------------------
        # start additions below
        # \  /
        #  \/
        # --------------------------
        data = {
            'row1': {'col1': 1, 'col2': 'a', 'col3': True},
            'row2': {'col1': 2, 'col2': 'b', 'col3': False},
            'row3': {'col1': 3, 'col2': 'c', 'col3': True}
        }

        df = pd.DataFrame.from_dict(data, orient='index')
        table = pn.widgets.Tabulator(df)

        button = pn.widgets.Button(name="Reset Table",button_type='primary')
            
        def button_click(event):

            table.value = pd.DataFrame(columns=['col1','col2','col3'])
            # Also tried:
            # t.value.drop(t.value.index,inplace=True)
            # and tried:
            # df_tmp = t.value
            # df_tmp = df_tmp.drop(t.value.index).copy()
            # t.value = df_tmp

        button.on_click(button_click)

        # --------------------------
        #  /\
        # /  \
        # end additions here
        # --------------------------

        return pn.Column(
            pn.pane.HTML('<h1>Bokeh Integration Example using Param and Panel</h1>'),
            pn.Row(
                button,     #<<====== add here
                table,      #<<====== add here
                pn.Column(
                    pn.panel(self.param, expand_button=False, expand=True, expand_layout=expand_layout),
                    "#### Subobject parameters:",
                    expand_layout),
                pn.Column(self.title, self.view)
            ),
            sizing_mode='stretch_width',
        )
  1. execute python manage.py migrate and then python manage.py runserver (I don't remember if it mattered whether migrate was executed)
  2. Open browser inspect panel and click on button

Environment:

python 3.12.9
Chrome/Firefox browser
pip freeze:

asgiref==3.8.1
attrs==25.1.0
autobahn==24.4.2
Automat==24.8.1
bleach==6.2.0
bokeh==3.6.3
bokeh-django @ git+https://github.com/bokeh/bokeh-django@533fbfd6439211526a6d8d52f3bea6f898c397a5
bokeh_sampledata==2024.2
certifi==2025.1.31
cffi==1.17.1
channels==4.2.0
charset-normalizer==3.4.1
constantly==23.10.4
contourpy==1.3.1
cryptography==44.0.1
daphne==4.1.2
Django==5.1.6
hyperlink==21.0.0
icalendar==6.1.1
idna==3.10
incremental==24.7.2
Jinja2==3.1.5
linkify-it-py==2.0.3
Markdown==3.7
markdown-it-py==3.0.0
MarkupSafe==3.0.2
mdit-py-plugins==0.4.2
mdurl==0.1.2
numpy==2.2.3
packaging==24.2
pandas==2.2.3
panel==1.6.1
param==2.2.0
pillow==11.1.0
pyasn1==0.6.1
pyasn1_modules==0.4.1
pycparser==2.22
pyOpenSSL==25.0.0
python-dateutil==2.9.0.post0
pytz==2025.1
pyviz_comms==3.0.4
PyYAML==6.0.2
requests==2.32.3
service-identity==24.2.0
setuptools==75.8.2
six==1.17.0
sqlparse==0.5.3
tornado==6.4.2
tqdm==4.67.1
Twisted==24.11.0
txaio==23.1.1
typing_extensions==4.12.2
tzdata==2025.1
uc-micro-py==1.0.3
urllib3==2.3.0
webencodings==0.5.1
xyzservices==2025.1.0
zope.interface==7.2

Appreciate any help or suggestions on this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions