Setting up Qt4 for PySide

I thought I should write down some notes on my travels across Python GUI dev, as it took me a while to set this up. The main reason was too many things to download, the Qt SDK is pretty massive.

Rather than listing all the wrong turns I took, I’ll just tell you what you need for getting up and running with PySide.

PySide requires Qt4 SDK, currently only Qt5 is available on the Qt website (by Digia). You have to traverse a bit far in, to reach the archives section, then go into the Qt directory, and download the last Qt4 version available. You do not need to install Qt Creator or anything else, just the Qt4 SDK. It is almost 1.2 GB, which really gave me second and third thoughts about installing it, but i had no choice (well…)

Once you install it somewhere safe, to start the designer go to C:\DEV\QtSDK\4.8.6\bin or wherever you installed it, and launch designer.exe.

This will give you the Qt4 designer.

Untitled

Create a new form and go for “Main Windows”. You can drag and drop stuff around, and it will generate a ui file for you. Thats all you need to from the designer.

Now the python side, yup, pySide. I did this in Windows, but most of the procedure should be similar in *nix.

First installed pySide via pip.

pip install pyside

It will also install another script/executable, pyside-uic.exe.

This is the file that converts the .ui file you generated in the designer into a .py python script that you can simply include into your project.

To generate the python code, just run:

pyside-uic.exe test.ui -o test.py

Now go back to your favourite IDE (pyCharm, right?) and include these files into your project.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s