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.
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
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With