使用cx_freeze后QGraphicsPixmapItem不会出现

发布于 2024-10-25 04:16:54 字数 1201 浏览 2 评论 0原文

我无法理解为什么在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以可爱出名 2024-11-01 04:16:54

所以我找到了我的问题的答案。显然问题不在于 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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文