Reputation: 688
When I click "View Code" in Qt Designer (PyQt4), it tries to show the C++ code.
So, the workaround is to run:
pyuic4.bat test.ui > test.py
to convert the file to .py
.
Is there a way to execute the above workaround every time "View Code" is clicked or should I have to always perform it manually?
The answer by @WithMetta in the duplicate solved my problem.
Upvotes: 0
Views: 3210
Reputation: 1684
I personally load those ui files on the fly without generating python code: something like this works for me:
import sys
from PyQt4 import QtCore,QtGui,uic
form_class, base_class = uic.loadUiType("unnamed.ui")
class MyWidget (QtGui.QWidget, form_class):
def __init__(self,parent=None,selected=[],flag=0,*args):
QtGui.QWidget.__init__(self,parent,*args)
self.setupUi(self)
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
form = MyWidget(None)
form.show()
app.exec_()
Upvotes: 3