我有以下代码:
import wx
from sys import platform
wildcard = "CSV files|*.csv|"\
"XML files|*.xml|"\
"Microsoft Excel files|*.xlsx" if platform == "win32" else "CSV files|*.csv|"\
"XML files|*.xml|"
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_1 = wx.Frame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
dlg = wx.FileDialog(
frame_1, message="Choose a file",
defaultDir="",
defaultFile="",
wildcard=wildcard, #PROBLEM IS HERE THAT'S FOR SURE
style=wx.OPEN
)
dlg.ShowModal() #IT CRASHES HERE
dlg.Destroy()
app.MainLoop()
此FileDialog在Windows和Linux中运行良好,但在Mac OS X中崩溃。为了让MacD X中的FileDialog正常工作,我有什么可以改变的吗?
Python 2.7.3,wxPython 2.8,Mac OS X 10.6
更新:已更新为小样本。
更新2:如果没有“通配符”参数,它的效果很好,但我还是需要通配符。
答案 0 :(得分:0)