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

Assertion and nextEventMatchingMask Error on MacOS when using wx.FileDialog called through flask/dash #2683

Open
matt-sd-watson opened this issue Jan 28, 2025 · 5 comments
Labels

Comments

@matt-sd-watson
Copy link

matt-sd-watson commented Jan 28, 2025

I am attempting to run a wx.Dialog popup through my flask/dash application with the following calback logic:

import wx
app = wx.App(None)
dialog = wx.FileDialog(None, 'Open', str(Path.home()), style=wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_FILE_MUST_EXIST,
                                   wildcard="*.tiff;*.tif;*.mcd;*.txt;*.h5;*.h5ad|*.tiff;*.tif;*.mcd;*.txt;*.h5;*.h5ad")
if dialog.ShowModal() == wx.ID_OK:
                filenames = dialog.GetPaths()
                if filenames is not None and len(filenames) > 0 and isinstance(filenames, list):
                    session_config = validate_session_upload_config(cur_session)
                    for filename in filenames: session_config["uploads"].append(filename)
                    dialog.Destroy()
                    return session_config
                dialog.Destroy()
                raise PreventUpdate
      dialog.Destroy()
      raise PreventUpdate
raise PreventUpdate

The dialog opens dynamically when the user selects a button.
This works perfectly fine on both Linux and Windows, but on MacOS I get the following error in the console trace:

2025-01-28 09:03:01.035 Python[16777:412914] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.
2025-01-28 09:03:01.035 Python[16777:412914] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], NSUndoManager.m:1117
2025-01-28 09:03:01.068 Python[16777:412914] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], NSUndoManager.m:1117
2025-01-28 09:03:01.077 Python[16777:412914] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], NSUndoManager.m:1117
2025-01-28 09:03:01.085 Python[16777:412914] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], NSUndoManager.m:1117
2025-01-28 09:03:01.092 Python[16777:412914] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], NSUndoManager.m:1117
2025-01-28 09:03:01.097 Python[16777:412914] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], NSUndoManager.m:1117

My current python environment (3.9.11) is set up with the following:

anndata==0.9.1
async-generator==1.10
attrs==23.1.0
beautifulsoup4==4.12.2
biopython==1.85
cachelib==0.9.0
certifi==2024.7.4
cffi==1.15.1
charset-normalizer==3.1.0
click==8.1.3
click-log==0.4.0
colorspacious==1.1.2
colour==0.1.5
contourpy==1.0.7
coverage==7.6.10
cryptography==43.0.1
cycler==0.11.0
Cython==0.29.35
dash==2.18.2
dash-ag-grid==2.3.0
dash-auth==2.0.0
dash-bootstrap-components==1.4.1
dash-core-components==2.0.0
dash-draggable==0.1.2
dash-extensions==1.0.1
dash-google-auth==0.1.2
dash-html-components==2.0.0
dash-mantine-components==0.12.1
dash-table==5.0.0
dash-testing-stub==0.0.2
dash_bio==1.0.2
dash_canvas==0.1.0
dash_daq==0.5.0
dash_tour_component==0.0.2
dash_uploader==0.7.0a1
dill==0.3.6
diskcache==5.6.1
dnspython==2.7.0
EditorConfig==0.12.3
exceptiongroup==1.1.1
fcswrite==0.6.2
Flask==2.2.5
Flask-Caching==2.0.2
Flask-Dance==7.0.0
Flask-HTTPAuth==4.8.0
fonttools==4.43.0
freeport==0.1.15
GEOparse==2.0.4
glasbey==0.2.0
h11==0.14.0
h5py==3.8.0
idna==3.7
igraph==0.10.4
imagecodecs==2023.9.18
imageio==2.31.0
imctools==2.1.8
importlib-metadata==6.6.0
importlib-resources==5.12.0
iniconfig==2.0.0
itsdangerous==2.1.2
Jinja2==3.1.5
joblib==1.2.0
jsbeautifier==1.14.8
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
kaleido==0.2.1
kiwisolver==1.4.4
lazy_loader==0.2
leidenalg==0.9.1
llvmlite==0.42.0
lxml==4.9.2
MarkupSafe==2.1.3
matplotlib==3.7.1
mongomock==4.1.2
more-itertools==9.1.0
multiprocess==0.70.14
natsort==8.4.0
nest-asyncio==1.6.0
networkx==3.1
numba==0.59.0
numexpr==2.8.8
numpy==1.24.3
oauthlib==3.2.2
opencv-python-headless==4.8.1.78
outcome==1.2.0
packaging==21.3
pandas==2.0.2
ParmEd==4.3.0
patsy==0.5.3
percy==2.0.2
periodictable==2.0.2
PhenoGraph==1.5.7
pillow==10.3.0
plotly==5.14.1
pluggy==1.0.0
psutil==5.9.5
pycparser==2.21
pydantic==1.10.13
pymongo==4.6.3
pynndescent==0.5.10
pyOpenSSL==24.2.1
pyparsing==3.0.9
PySocks==1.7.1
pytest==7.3.1
pytest-cov==4.0.0
python-dateutil==2.8.2
pytz==2023.3
PyWavelets==1.4.1
rakaia @ file:///Users/mattw/github/rakaia
readimc==0.7.0
referencing==0.36.2
requests==2.32.3
requests-oauthlib==1.3.1
retrying==1.3.4
rpds-py==0.22.3
scanpy==1.9.3
scikit-image==0.21.0
scikit-learn==1.5.0
scipy==1.10.1
seaborn==0.12.2
selenium==4.2.0
sentinels==1.0.0
session_info==1.0.0
shortuuid==1.0.12
six==1.16.0
sniffio==1.3.0
sortedcontainers==2.4.0
soupsieve==2.4.1
statsmodels==0.14.0
stdlib-list==0.8.0
steinbock==0.16.1
tenacity==8.2.2
texttable==1.6.7
threadpoolctl==3.1.0
tifffile==2023.8.12
tomli==2.0.1
tqdm==4.66.3
trio==0.22.0
trio-websocket==0.10.2
typing_extensions==4.8.0
tzdata==2023.3
umap-learn==0.5.2
urllib3==1.26.19
urllib3-secure-extra==0.1.0
URLObject==2.4.3
waitress==3.0.1
Werkzeug==3.0.6
wsproto==1.2.0
wxPython==4.2.0
xmltodict==0.13.0
xtiff==0.7.9
zipp==3.19.1
@matt-sd-watson matt-sd-watson changed the title Assertion and nextEventMatchingMask Error on MacOSwhen using wx.FileDialog Assertion and nextEventMatchingMask Error on MacOSwhen using wx.FileDialog called through flask/dash Jan 28, 2025
@swt2c
Copy link
Collaborator

swt2c commented Jan 28, 2025

Hard to say without a small, self-contained example but the error message suggests you might be making wxPython calls from a non-main thread. Is that a possibility?

@matt-sd-watson
Copy link
Author

The application is almost certainly running in a multi threaded mode.

@swt2c
Copy link
Collaborator

swt2c commented Jan 28, 2025

That's likely the problem then. wxPython (GUI) calls have to be made from the main thread.

@matt-sd-watson
Copy link
Author

matt-sd-watson commented Jan 28, 2025

Any insight into the difference in GUI handling for wxPython across different operating systems? When I run my application multi-threaded on either Windows or Linux, the dialog opens and functions perfectly fine.

@swt2c
Copy link
Collaborator

swt2c commented Jan 28, 2025

You're just getting lucky on Windows and Linux.

You could try wrapping your GUI code with wx.CallAfter():
https://wiki.wxpython.org/CallAfter

@matt-sd-watson matt-sd-watson changed the title Assertion and nextEventMatchingMask Error on MacOSwhen using wx.FileDialog called through flask/dash Assertion and nextEventMatchingMask Error on MacOS when using wx.FileDialog called through flask/dash Jan 28, 2025
@swt2c swt2c added the question label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants