Yes, I am completely new to Python. I've been using Perl and Java for years and want to start using Python.

But, at the same time, I'm working on projects in Perl and C++ (which I'm also learning) and I've installed Qt on my system, which is an iMac running OS X 10.8.4. I downloaded and built Qt 5.1.1, then installed Sip and PyQt. Then I wanted to test and be sure PyQt was working and the new Qt install overall, too. I figured it'd be quicker to test in Python than with a C++ example (and I'm having difficulties dealing with Perl - Qt on Perl is on hold).

I found this page http://pyqt.sourceforge.net/Docs/PyQt5/designer.html with some basic information on using PyQt. Other pages talk about using pyuic, but this page says it's included and that .ui files from Qt Designer will be parsed automatically by the Qt modules. So I used Qt Designer and tried to create a simple dialog - with just Cancel and Okay buttons and I saved the file, using the names specified on the linked page. Then I renamed ui_imagedialog.ui to ui-imagedialog.py (as specified in the tutorial) and created the program file by cutting and pasting this code in my text editor:

When I first set this up and tried it, I had not renamed ui_imagedialog.ui to ui_imagedialog.py and I got an error on the 5th line ("from ui_imagedialog import..."), which tells me that in Python, if a resource is not there, I get an error at the line where I'm trying to import. Since I didn't get any errors from the 4th line, that makes me think PyQt5 is visible and available (meaning I installed it correctly).

But once I did rename ui_imagedialog.ui to ui_imagedialog.py, I find I get this error:

It's having trouble from the very first line in ui_imagedialog.py. According to the information on the page with this example, the .ui file is supposed to be renamed to a .py file and is supposed to be parsed by the uic module that PyQt5 uses. I figure it is being read and treated as a Python file and not being parsed as the page the code is from states.

What am I doing wrong and what do I need to change so the .ui file is parsed as it should be?

PyQt5 does not wrap the QUiLoader class but instead includes the uic Python module. Like QUiLoader this module can load .ui files to create a user interface dynamically. Like the uic utility it can also generate the Python code that will create the user interface. PyQt5’s pyuic5 utility is a command line interface to the uic module. Both are described in detail in the following sections.

Okay. I was reading it as it was definitely stating that the ui file would be parsed automatically and had re-read it several times and came to that conclusion.

But I figured if you were getting a different interpretation then I needed to re-examine the situation. Part of the problem is I have not been able to find pyuic5 on my system anywhere, so I wondered if it was really needed or just what was going on. I even used the find command to try to locate it.

It turns out pyuic is in the /Library directory tree - but there was a permissions issue, which very well could be my fault. Anyway, I found it using find as root, fixed the issue, and added the bin directory with pyuic5 to my path so it works now.

I've contacted them about the wording of that paragraph. You clearly understood it correctly, but it did sound to me like a new ability to parse the file directly was built in on PyQt5, so I've contacted the developers about that. I think a little bit of re-writing would make a world of difference.