Skip to content Skip to sidebar Skip to footer

Setting Up PySide/Qt For GUI Development

I have been trying to setup PySide/Qt for use with Python3.3. I have installed PySide-1.2.0.win32-py3.3.exe that I took from here and I have installed qt-win-opensource-4.8.5-v

Solution 1:

This error:

FileNotFoundError: [WinError 3] The system cannot find the path specified.

will be fixed in next pyside release (1.2.1). It will be released in next week.

btw: in case you don't want to generate custom bindings, you don't need to install qt, pyside installer contains all qt libraries and devel tools.


Solution 2:

Regarded FileNotFoundError, I had a problem packaging a python 3 application with this for a few days. On a windows 7 64 bit machine it worked fine. When I built it on win7 32bit and tried to run the .exe file, I got all those file errors. After seeing this thread I checked the versions of pyside. On the win64 it was 1.1.2 on the win32 it was 1.2.0 I uninstalled pyside 1.2.0 on win32 and downloaded and installed the 1.1.2 win32 version. It now works ok. This could be a stop gap measure until 1.2.1 is released.


Solution 3:

I'm doing something similar (however I'm in the progress of migrating from PyQt to PySide).

You should use pyside-uic to generate the code for the GUI after creating the UI files in QtCreator (If this were PyQt "pyuic gui.ui > gui.py" would produce the desired code, I assume pyside-uic has a similar behaviour). I then subclass this generated code to customise the user interface.

Yes, you can use cx_freeze with PyQt/PySide, you'll want to include PySide in the "includes" item in the build options.

Yes, you can create a completely self-contained executable - you won't need Python, Qt or anything else.

Here's the build I use from my PySide GUI application.

__author__ = 'AlexM'
import sys
from cx_Freeze import setup, Executable
import MyPySideGui
import PySide, os

base = None
if sys.platform == "win32":
    base = "Win32GUI"

QGifRelDir = "imageformats\qgif4.dll"
PySideDir = (os.path.join(os.path.dirname(PySide.__file__),"plugins"))

shortcut_table = [
    ("App Shortcut",                 # Shortcut
     "ProgramMenuFolder",            # Directory_
     "MyPySideGUI",                  # Name
     "TARGETDIR",                    # Component_
     "[TARGETDIR]MyPySideApp.exe",   # Target
     None,                           # Arguments
     None,                           # Description
     None,                           # Hotkey
     None,                           # Icon
     None,                           # IconIndex
     None,                           # ShowCmd
     'TARGETDIR'                     # WkDir
     )
]

build_exe_options = {
    "include_files" : ["documentTemplate.html", "loading.gif", (os.path.join(PySideDir,QGifRelDir), QGifRelDir)],
    "packages" : ["CustomHelperPackage", "AnotherCustomPackage", "MyPySideGui"],
    "includes" : ["PySide"],
    "excludes" : ["tkinter"],
    'optimize': 2,
}

# Now create the table dictionary
msi_data = {"Shortcut": shortcut_table}

# Change some default MSI options and specify the use of the above defined tables
bdist_msi_options = {'data': msi_data}

executables = [ Executable("MyPySideGui.py", base = base) ]

setup(
    name = "MyFirstPySideApplication",
    version = str(MyPySideGui.version),
    description = "MyPySideApp.exe Demonstrates PySide guis.",
    options = {
        "build_exe": build_exe_options,
        "bdist_msi": bdist_msi_options
    },
    executables = executables
)

This example might be slightly complicated for you, but you can find simpler examples on the cx_freeze project homepage.

I'm not getting the issues you or the other answer are getting, but then I'm using Python 3.3.1 with PySide 1.1.2.


Solution 4:

PySide 1.2.1 was released. It has fixed the error. I checked it by installing the new version and using cx_freeze.

No error in packaging with cx_freeze 4.3.1(32-bit version for Python 3.3) used with Python 3.3.2(32-bit) and PySide 1.2.1(32-bit) on Windows 7(64-Bit). I used the command written in the question to package it. It worked successfully.


Post a Comment for "Setting Up PySide/Qt For GUI Development"