Question

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.

Was it helpful?

Solution

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top