py2exe 与其源 .py 文件的行为不一致
我的 python 程序有很多函数,当从 .py 脚本运行时,它们似乎都工作正常。使用 py2exe 编译后,代码的几个部分的行为非常不一致。
这一部分似乎与它的失败非常一致。
def unzipItem(self, fileName, destination):
print "--unzipItem--"
zip = zipfile.ZipFile(fileName)
nameList = zip.namelist()
fileCount = 0
for item in nameList:
fileCount += 1
dlg = wx.ProgressDialog("Unziping files",
"An informative message",
fileCount,
parent = self,
)
keepGoing = True
count = 0
for item in nameList:
count += 1
dir,file = os.path.split(item)
print "unzip " + file
self.SetStatusText("Unziping " + str(item))
(keepGoing, skip) = dlg.Update(count, file)
zip.extract(item,destination)
zip.close()
dlg.Destroy()
ProcessDialog 永远不会出现,SetStatusText 也永远不会更新 GUI。
My python program has many function which all seem to work fine when run from the .py script. After compiling with py2exe several of the sections of code have very inconsistent behavior.
This section seems to be very consistent in its failure.
def unzipItem(self, fileName, destination):
print "--unzipItem--"
zip = zipfile.ZipFile(fileName)
nameList = zip.namelist()
fileCount = 0
for item in nameList:
fileCount += 1
dlg = wx.ProgressDialog("Unziping files",
"An informative message",
fileCount,
parent = self,
)
keepGoing = True
count = 0
for item in nameList:
count += 1
dir,file = os.path.split(item)
print "unzip " + file
self.SetStatusText("Unziping " + str(item))
(keepGoing, skip) = dlg.Update(count, file)
zip.extract(item,destination)
zip.close()
dlg.Destroy()
The ProcessDialog never appears, and the SetStatusText never updates the GUI.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于为什么会发生这种情况,并不是真正的答案 - 但使用 cx_Freeze 而不是 py2exe 解决了这个问题。
Not a real answer as to why this occured - but using cx_Freeze instead of py2exe solved this problem.