You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mixed problems with this using pyscript. Last attempt saw the drag action working, but the default behavior of the action continued to open the file in another browser window. It shouldn't. Further, the listener didn't seem to pick up on the action to trigger it.
asyncdefdnd_file_select(event):
"""Handle file select and follow-on actions from HTML/Pyscript."""clear_data()
event.stopPropagation()
event.preventDefault()
DRAG_AND_DROP="Drag and drop is not yet supported, please use the file-picker"document.getElementById("content").contentDocument.body.innerText=DRAG_AND_DROPreturnFalsedefhandle_drop_over(event):
"""Manage the drop-over event."""event.stopPropagation()
event.preventDefault()
event.dataTransfer.dropEffect="copy"console.log("Registered drop-over")
defsetup_button():
# Create a Python proxy for the callback functionfile_select_proxy=create_proxy(file_select)
dnd_file_select_proxy=create_proxy(dnd_file_select)
handle_drop_over_proxy=create_proxy(handle_drop_over)
# Set the listener to the callbackdocument.getElementById("file_select").addEventListener(
"click", file_select_proxy, False
)
# Setup the drag-and-drop listeners.## Pyscript may not support this yet...#dz=document.getElementById("drop_zone")
dz.addEventListener("dragover", handle_drop_over_proxy, False)
dz.addEventListener("drop", dnd_file_select_proxy, False)
console.log("File handler registered")
<divclass="drag" id="drop_zone"><labelclass="custom-file-upload"><inputtype="file" id="file_select" name="files[]" single/>
Choose file
</label>
or drop files here
</div>
Mixed problems with this using pyscript. Last attempt saw the drag action working, but the default behavior of the action continued to open the file in another browser window. It shouldn't. Further, the listener didn't seem to pick up on the action to trigger it.
Drag-and-drop code is based on HTML5 rocks: https://www.html5rocks.com/en/tutorials/file/dndfiles//
The text was updated successfully, but these errors were encountered: