tags:

views:

47

answers:

2

I'm trying to compile my first .ui file using PyQt4 on a mac with osx 10.6. I'm getting a syntax error and I'm not sure what it means.

>>> import sys
>>> sys.path.append('/Users/womble/Dropbox/scratch/')
>>> from PyQt4 import QtCore, QtGui
>>> pyuic4 Urb.ui > Urb.py

File "<stdin>", line 1
    pyuic4 Urb.ui > Urb.py
             ^
SyntaxError: invalid syntax

I tried adding

#!/usr/bin/python2.5

as my first line to the .ui file and I still get the same problem.

Thanks for any suggestions.

+1  A: 

You're mixing Python and shell commands.

This is Python code and can be executed from an interactive Python session:

import sys
sys.path.append('/Users/womble/Dropbox/scratch/')
from PyQt4 import QtCore, QtGui

This is supposed to be run from a command prompt or terminal window. It's giving syntax errors in your Python interpreter because it's not Python:

pyuic4 Urb.ui > Urb.py
Josh Kelley
thanks - that sorted out my problem!
celenius
A: 

I normally use pyuic4 from the command line in the following way:

pyuic4 -xo Urb.py Urb.ui

The x flag makes sure the generated Python code includes a small amount of additional code that creates and displays the GUI when it is executes as a standalone application.

The o flag specifies the output file to write to (in the example above: Urb.py)

ChristopheD