askopenfile not working on Mac. Switch to javascript open file window.
mathewthe2 opened this issue · 0 comments
mathewthe2 commented
tkinter and askopen file won't work on Mac because it is running on a different thread.
It is also blocked on Windows sometimes by other tasks.
Remove tkinter and use javascript .
Example
function openFileDialog (accept, callback) { // this function must be called from a user
// activation event (ie an onclick event)
// Create an input element
var inputElement = document.createElement("input");
// Set its type to file
inputElement.type = "file";
// Set accept to the file types you want the user to select.
// Include both the file extension and the mime type
inputElement.accept = accept;
// set onchange event to call callback when user has selected file
inputElement.addEventListener("change", callback)
// dispatch a click event to open the file dialog
inputElement.dispatchEvent(new MouseEvent("click"));
}