Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

FileInput - filenames not displayed #38

Open
thuydotm opened this issue Jan 3, 2025 · 0 comments
Open

FileInput - filenames not displayed #38

thuydotm opened this issue Jan 3, 2025 · 0 comments

Comments

@thuydotm
Copy link
Collaborator

thuydotm commented Jan 3, 2025

Chosen files were uploaded successfully but their names didn't appear in the FileInput widget so user may get confused whether the upload has been done or not.

import panel as pn
from panel_material_ui import *

pn.extension(template='material', defer_load=True)

file_input = FileInput(accept='.txt,.csv')  # Accept only .txt and .csv files

# Callback function to handle the uploaded file
def handle_file(event):
    if file_input.value:
        file_content = ",".join(file_input.filename)
        # Display content in a TextArea for visualization
        textarea.value = file_content

# Link the callback to the value change event
file_input.param.watch(handle_file, 'value')

# TextArea to display file content
textarea = TextAreaInput(value='', height=300, width=500, placeholder='Uploaded files will appear here.')

pn.Column(
    pn.pane.Markdown("### File Upload Example"),
    file_input,
    textarea,
).servable()
Screen.Recording.2025-01-03.at.23.08.28.mov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant