I am a beginner with python and started using Eclipse very recently. I am using Qt-designer and created a file named MyWidget.ui, but while running the program I receive an error:
from PyQt4.uic.Loader.loader import DynamicUILoader
ImportError: No module named Loader.loader
import sys
from PyQt4 import QtGui, uic
class MyWindow(QtGui.QMainWindow):
def __init__(self):
super(MyWindow, self).__init__()
uic.loadUi('MyWidget.ui', self)
self.show()
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
MyWindow.show()
sys.exit(app.exec_())
1 Design a user interface in QT4 Designer. Save as a .ui file (XML).
2 Generate Python code from the UI file using pyuic.
pyuic4.bat -x myForm.ui > myForm.py On Windows it's bat file pyuic4 -x myForm.ui > myForm.py On Linux it's a script
3 Test the UI. The '-x' option to pyuic causes it to emit a built-in test program so you can just run myForm.py from the command line to test it.
4 Create a python wrapper with the event loop in it. For example, this is similar to what the '-x' option gives you.
将一个空的__init__.py
文件放在“ \\ site-packages \\ PyQt4 \\ uic \\ Loader”子目录中。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.