Bug in wxPython? MessageDialog.ShowModal() returning always zero on OS X
Jari Nevala <[email protected]>
| Newsgroups | gmane.comp.python.wxpython.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I noticed recently that when a MessageDialog is created in a thread and its
ShowModal() is called, it always returns 0 on OS X. This is an error,
because it should return the wx.ID of the button pressed. On Windows this
does not happen.
When the MessageDialog is created in the main thread, the ShowModal()
returns correct value on OS X and PC.
The Mac I used to reproduce this problem is Macbook Air with OS X version
10.9.5. wxPython version is 3.0.2.0. My PC is running Windowsx 8.1 and also
has wxPython 3.0.2.0 installed.
Below is code to reproduce the problem. See the comments.
Code also available in pastebin: http://pastebin.com/QbNkw5gz
So is this a bug in wxPython?
1. import os
2. import wx
3. import threading
4.
5. class MyClass(wx.App):
6. def __init__(self, redirect=False, filename=None):
7. wx.App.__init__(self, redirect, filename)
8. self.frame = wx.Frame(None, title='Blah blah')
9. self.panel = wx.Panel(self.frame)
10. self.frame.Show()
11. self.startBtn = wx.Button(self.panel, size=(140,40), label=
'Start')
12. self.startBtn.Bind(wx.EVT_BUTTON, self.onStart)
13. self.panel.Layout()
14.
15. dlg = wx.MessageDialog(None, "foo", "bar", wx.YES_NO)
16. result = dlg.ShowModal()
17. print "dialog result: ",result #prints 5103 (wx.ID_YES) or
5104 (wx.ID_NO) both on Windows and OS X
18. dlg.Destroy()
19.
20.
21. def onStart(self, event):
22. test = "test1"
23. self.t = threading.Thread(target=self.testThread, args = (
self, test))
24. self.t.daemon = False
25. print "Starting thread:", test
26. self.t.start()
27.
28. def testThread(self, a, test):
29. dlg = wx.MessageDialog(None, test, test, wx.YES_NO)
30. result = dlg.ShowModal()
31. print "dialog result: ",result #prints 5103 (wx.ID_YES) or
5104 (wx.ID_NO) on Windows, but always 0 on OS X
32. dlg.Destroy()
33.
34. if __name__ == '__main__':
35. app = MyClass()
36. app.MainLoop()
--
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.