Hi, all
I have a similar problem. In windows the fallowing script works fine, but using wx3.0.0-cocoa-mavericks the first dialog canceled automatically (print(rspns) is 5101 = wx.ID_CANCEL) and only the second dialog show appropriately :
from future import print_function
import os
import wx
CWD = os.getcwd()
class MyApp(wx.App):
def OnInit(self):
dlg_open = wx.FileDialog(None, ‘Select file’, CWD, ‘’,
wildcard=‘All(.)|.’,
style=wx.OPEN)
rspns = dlg_open.ShowModal()
if rspns == wx.ID_OK:
print(dlg_open.GetPath())
else:
print(rspns)
dlg_open.Destroy()
dlg_open = wx.FileDialog(None, ‘Select other file’, CWD, ‘’,
wildcard=‘All(.)|.’,
style=wx.OPEN)
rspns = dlg_open.ShowModal()
if rspns == wx.ID_OK:
print(dlg_open.GetPath())
else:
print(rspns)
dlg_open.Destroy()
return True
if name == “main”:
app = MyApp()
app.MainLoop()
This does not happen when the dialog has a parent, in this case all is ok:
from future import print_function
import os
import wx
CWD = os.getcwd()
class MyFrame(wx.Frame):
def init(self, parent, id_=wx.ID_ANY, title=“”,
pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.DEFAULT_FRAME_STYLE):
super(MyFrame, self).init(parent, id_, title,
pos, size, style)
self.panel = wx.Panel(self)
btn = wx.Button(self, -1, ‘Open’, (50,50))
self.Bind(wx.EVT_BUTTON, self.on_button, btn)
def on_button(self, event):
dlg_open = wx.FileDialog(self, ‘Select file’, CWD, ‘’,
wildcard=‘All(.)|.’,
style=wx.OPEN)
rspns = dlg_open.ShowModal()
if rspns == wx.ID_OK:
print(dlg_open.GetPath())
else:
print(rspns)
dlg_open.Destroy()
dlg_open = wx.FileDialog(self, ‘Select file’, CWD, ‘’,
wildcard=‘All(.)|.’,
style=wx.OPEN)
rspns = dlg_open.ShowModal()
if rspns == wx.ID_OK:
print(dlg_open.GetPath())
else:
print(rspns)
dlg_open.Destroy()
class MyApp(wx.App):
def OnInit(self):
self.frame = MyFrame(None, title=“The Main Frame”)
self.SetTopWindow(self.frame)
self.frame.Show()
return True
if name == “main”:
app = MyApp()
app.MainLoop()
···
El martes, 11 de febrero de 2014 16:53:55 UTC+1, David Hughes escribió:
I’m in the process of migrating a Python 2.7 application from using wx.2.9.4 osx-carbon that supported ppc-i386 to wx.3.0.0 osx-cocoa (i386-x86_64) and finding that a modal wx.message dialog opened during wx.App.OnInit() just flashes up briefly before the OnInit code continues. The attached standalone showmessage.py demonstrates the problem here and the 3 screenshots show it working OK with wx.2.9.4 osx-carbon (Snow Leopard) and wx.3.0.0 win32 (Windows8.1) but not wx.3.0.0 osx-cocoa (Mavericks). Can anyone else reproduce this? The wx.message samples in the wx 3.0.0 demo seem to be OK, which makes me think the problem is related to being inside OnInit()
Regards
David Hughes