Until now, I have been developing my GUIs by creating the user interface with QtDesigner, saving the file as file.ui
and using pyuic4
to create the file.py
.
However, quite recently I have read that it is not necessary to create the file.py
. I can just load the file.ui
by doing :
class MyWindow(QtGui.QMainWindow):
def __init__(self):
super(MyWindow, self).__init__()
uic.loadUi('file.ui', self)
self.show()
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
window = MyWindow()
sys.exit(app.exec_())
This might work, it actually works because I have tested it.
My questions are:
1- Is this way better than the other or not? and why?
2- If I use this seccond option, how do I make the connections of the buttons, event etc?