我想用wx.FileDialog做了一个打开文件的demo,但是我发现每次打开文件都会卡很久才能打开。除非是特别特别小的txt文件,才不会出现这样的问题,这个是为什么呢?如何解决?
就在执行下面这句代码的时候,就会很卡:
def onSaveFile(self,event):
"""
Create and show the Save FileDialog
"""
dlg = wx.FileDialog(self,
message="select the Save file style",
defaultFile="",
wildcard=wildcard2,
style=wx.SAVE
)
if dlg.ShowModal() == wx.ID_OK:
filename=""
paths = dlg.GetPaths()
#split the paths
for path in paths:
filename=filename+path
#write the contents of the TextCtrl[Contents] into the file
file=open(filename,'w')
file.write(Contents.GetValue())
file.close()
#show the save file path
TxtCfn.SetValue(filename)
dlg.Destroy()
我仔细排查了一下 就是 dlg.ShowModal() == wx.ID__OK: 这句话会很卡。