使用cx_freeze后QGraphicsPixmapItem不会出现
我无法理解为什么在使用 cx_freeze 构建应用程序后我的 QGraphicsPixmapItem 没有显示。该类和 cx_freeze 是否存在任何已知问题,或者我是否缺少 cx_freeze 的某些设置?这是创建和显示 QGraphicsPixmapItem 的部分,之后是我的 cx_freeze 的 setup.py:
def partNo_changed(self):
self.scene.removeItem(self.previewItem)
partNumber = self.ui.partNo.text()
fileLocation = 'drawings\\FULL\\%s.svg' % partNumber
print(fileLocation)
pixmap = QtGui.QPixmap(fileLocation)
self.previewItem = QtGui.QGraphicsPixmapItem(pixmap)
self.previewItem.setPos(0, 0)
self.scene.addItem(self.previewItem)
self.ui.svgPreview.centerOn(self.previewItem)
这是 setup.py 脚本:
from cx_Freeze import setup, Executable
files = ['drawings\\FULL']
setup(
name = 'DBManager',
version = '1.0',
description = 'Makes and maintains the .csv database files.',
author = 'Brock Seabaugh',
options = {'build_exe': {'include_files':files, 'bin_path_includes':files}},
executables = [Executable('dbManager_publicDB.py')])
程序中的其他所有内容都有效,这是唯一不起作用的东西(它有效)如果我只是运行 .py 脚本,但不是在运行 exe 时运行)。当我构建或运行 exe 时,我没有收到任何错误。如果有人能帮忙解决这个问题那就太好了。我正在使用 Python v3.1 和 cx_freeze v4.2.3 和 PyQt v4。
I am having trouble understanding why my QGraphicsPixmapItem is not showing up after I build the application using cx_freeze. Are there any known issues with that class and cx_freeze or am I missing some settings with cx_freeze? Here is the part that is creating and displaying the QGraphicsPixmapItem and after that is my setup.py for cx_freeze:
def partNo_changed(self):
self.scene.removeItem(self.previewItem)
partNumber = self.ui.partNo.text()
fileLocation = 'drawings\\FULL\\%s.svg' % partNumber
print(fileLocation)
pixmap = QtGui.QPixmap(fileLocation)
self.previewItem = QtGui.QGraphicsPixmapItem(pixmap)
self.previewItem.setPos(0, 0)
self.scene.addItem(self.previewItem)
self.ui.svgPreview.centerOn(self.previewItem)
and here is the setup.py script:
from cx_Freeze import setup, Executable
files = ['drawings\\FULL']
setup(
name = 'DBManager',
version = '1.0',
description = 'Makes and maintains the .csv database files.',
author = 'Brock Seabaugh',
options = {'build_exe': {'include_files':files, 'bin_path_includes':files}},
executables = [Executable('dbManager_publicDB.py')])
Everything else works in the program, this is the only thing that is not working(it works if I just run the .py script, but not when I run the exe). I get no errors when I build or run the exe. If someone could help with this that would be great. I am using Python v3.1 and cx_freeze v4.2.3 and PyQt v4.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以我找到了我的问题的答案。显然问题不在于 QGraphicsPixmapItem 类,而在于应用程序的 QtSvg 部分。这让我很失望,因为 cx_freeze 的输出显示创建可执行文件时包含了 QtSvg 模块,但这并不是程序所需的全部。它还需要 qt.conf 文件。要解决这个问题,我所要做的就是在 '...\Python31\Lib\site-packages\PyQt4\bin\qt.conf' 中找到 qt.conf 文件,然后将该文件复制到应用程序可执行文件的目录中瞧,它起作用了!
So I found the answer to my question. Apparently the problem wasn't with the QGraphicsPixmapItem class, it was with the QtSvg portion of the application. Which threw me off because cx_freeze's output showed that the QtSvg Module was included when creating the executable, but that is not all that is needed by the program. It needs the qt.conf file also with it. All I had to do to fix the problem was go find the qt.conf file at '...\Python31\Lib\site-packages\PyQt4\bin\qt.conf' and copy that file to the directory where your application's executable is at and voilà, it works!