-
Notifications
You must be signed in to change notification settings - Fork 10
issue with AsyncShowDialog and AsyncShowDialogModal on macos (abort crash) #20
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
Comments
Hi @BrendanSimon, thanks for reporting this issue. See the following code which works on windows but crashes on macos: import wx
import time
from threading import Thread
class TestFrame(wx.Frame):
def __init__(self, parent=None):
super(TestFrame, self).__init__(parent)
vbox = wx.BoxSizer(wx.VERTICAL)
button1 = wx.Button(self, label="Submit")
vbox.Add(button1, 2, wx.EXPAND|wx.ALL)
vbox.AddStretchSpacer(1)
self.Bind(wx.EVT_BUTTON, self.OnOpen, button1)
self.SetSizer(vbox)
self.Layout()
def OnOpen(self, event):
thread = Thread(target=self.thread_main)
thread.start()
def thread_main(self):
with wx.FileDialog(self, "Open XYZ file", wildcard="XYZ files (*.xyz)|*.xyz",
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) as fileDialog:
if fileDialog.ShowModal() == wx.ID_CANCEL:
return
def main():
app = wx.App()
frame = TestFrame()
frame.Show()
app.SetTopWindow(frame)
app.MainLoop()
main() |
There are also the options of ShowWindowModal or ShowWindowModalThenDo. It's not so clear what would be the best solution. Would you have any idea? |
I'm not aware of the other ShowWindow functions. The wxwigets/wxpython discussion group is probably the best for those. Probably the best option to call the dialog from a thread is https://docs.wxpython.org/wx.CallLater.html Does I thought the idea of wxasync was to run everything in the main gui thread. |
OS level dialogs, like FileDialog, DirDialog, ColourDIalog only support (wx.CallAfter and wx.CallLater won't change anything about this) I have no idea what pattern could be used for macOS, or how to update wxwidgets to improve this. |
I just checked out the latest master and tried running the examples with latest Python 3.9 and wxPython snapshot on macOS.
I tried with Python 3.10 too.
These might be wxPython snapshot issues and/or macOS specific issues?
(venv-3.9) ➜ examples git:(master) % python dialog.py The ReturnCode is 5100 and you entered 'asdfasdfasdf' objc[60344]: autorelease pool page 0x7fda0f8b5000 corrupted magic 0x00000000 0x00000000 0x00000000 0x00000000 should be 0xa1a1a1a1 0x4f545541 0x454c4552 0x21455341 pthread 0x10e199600 should be 0x10e199600 [1] 60344 abort python dialog.py (venv-3.9) ➜ examples git:(master) %
The text was updated successfully, but these errors were encountered: