installing PyQt4 and Python2.6.6 to make a dialog box

Having trouble installing or compiling FreeCAD? Get help here.
Posts: 10
Joined: Sun Apr 28, 2013 8:44 pm

installing PyQt4 and Python2.6.6 to make a dialog box

Postby spgandau » Sat Aug 24, 2013 3:22 pm


This is FYI for those who consider themselves competent users, but are struggling through the Dialog creation and conversion from *.ui to *.py
I was going through the FreeCAD help files and got 'stuck' when I tried to use the QT designer feature to create a dialog box and then convert it from a *.ui format to a *.py format.
I installed the most recent version of Qt, thinking it would be what I needed. I successfully created the dialog box.
The "pyuic" (or pyuic4) code would not execute. I navigated down thru FreeCAD to the PyQt folder and tried from there. (I used the cmd line to navigate to the proper folder, and tried the execute "pyuic").
I extracted the file within FreeCAD, and the Python26 folder and files were created, and re-tried the pyuic (and pyuic4) conversion to *.py. no success.

So, using *.exe files, I downloaded and installed Python version 2.6.6. ( I could not find an old version Python 2.6.2, so I used 2.6.6)
I uninstalled Qt. Next, I tried to install an older version of Qt that would work with the Python version 2.6.6.
After several attempts, I finally found and installed Qt version 4.8.4 (VS2008) 32bit.

I was then able to follow the help file directions to create the dialog box. I saved it as a *.ui file. Then, I tried to again use pyuic (and pyuic4) to convert to a *.py format. no luck.
I began looking for PyQt installations that might work. I finally discovered one PyQt4 version that would work with my installed version of Python 2.6.6.
I used: ... PyQt-4.10/
I selected: PyQt4-4.10-gpl-Py2.6-Qt4.8.4-x32.exe and installed it. I used the PyQt Designer to create the dialog box, per the instructions in the FreeCAD help file. (So,it seems that I did not need Qt 4.8.4 )
I re-tried the FreeCAD help file 'Dialog creation' lesson, and made the conversion from *.ui to *.py successfully.
(I noticed that Python 2.6.6 installed a path into the environment variable called: C:\Python26\Lib\site-packages\PyQt4. I assume that the pyuic4 command is from that path location)

what i am a bit confused about is the fact that FreeCAD0.13 1828 shows PyQt4 and Python26 under the bin folder. I wonder if my FreeCAD0.13 did not install completely / correctly?
Install location: c:\program files (x86)\FreeCAD0.13
Or....maybe I don't understand how to correctly use the Python console within FreeCAD..? either way, I finally got the dialog box lesson to convert to *.py
Now..... on to make it actually function in FreeCAD. :P
Posts: 2744
Joined: Wed May 16, 2012 2:13 pm

Re: installing PyQt4 and Python2.6.6 to make a dialog box

Postby mario52 » Wed Sep 04, 2013 9:21 am

try with these methods
[PyQt] Boîte de dialogue
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Dialog creation. My macros on Gist.github.
User avatar
Site Admin
Posts: 11616
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil

Re: installing PyQt4 and Python2.6.6 to make a dialog box

Postby yorik » Wed Sep 04, 2013 2:51 pm

Good to see you finally had it working. I'lll add some info in case someone else falls here looking for help.

Basically applications that provide a bundled python package, such as freecad or blender, usually do like you saw yourself: they carry a zipped python package, that they use internally. What is inside that package might not be a python installation, developers might have stripped out some pieces that are unnecessary for them. So you are always advised to install a complete python package first, to make sure you have a complete python installation. Choose a python package with the same version number as the one used in freecad, to make sure it is 100% compatible.

The pyuic program (which stands for Python-UI Converter) is a small program used to convert a .ui file to .py. A Ui files are xml files that describe all the contents of a widget, and when converting it to python code, the pyuic program simply creates a lot of python instructions that use pyqt to recreate the widget. Finding how to get that program can be tricky, since it is a small program, it is usually packaged in another bigger package, such as pyqt.

The fact that freecad installs several packages under its bin folder is normal. That bin folder is always found by the freecad python interpreter, so it is convenient to add our "custom" python packages there, we are sure they will be found, whatever the folder where freecad is installed, and whatever the OS freecad is running.