Start

Erste Fenster

import sys
from PyQt5.QtWidgets import QApplication, QMainWindow

class GUI(QMainWindow):

    def __init__(self):
    super().__init__()
    self.initUI()

    def initUI(self):
    self.setWindowTitle("Alstat")
    self.resize(400, 300)
    self.add_widgets()

    def add_widgets(self):
    self.statusBar().showMessage('Los gehts')

if __name__ == '__main__':
    app = QApplication(sys.argv)
    gui = GUI()
    gui.show()
    sys.exit(app.exec_())

UI zu Python-Script

pyuic5 -x -o alstatui.py alstat.ui

Modularisierung

Trennung von Designer-Code (alstatui.py) und eigenen Anpassungen

from PyQt5 import QtWidgets
from alstatui import  Ui_MainWindow


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())