Skip to content

Instantly share code, notes, and snippets.

@jigi-33
Last active February 21, 2022 14:09
Show Gist options
  • Save jigi-33/f8c947645b1036d579e953805c553f18 to your computer and use it in GitHub Desktop.
Save jigi-33/f8c947645b1036d579e953805c553f18 to your computer and use it in GitHub Desktop.
Рыба (эталон) главного скрипта при подключении внешнего UI, сгенеренного QtDesigner'ом

The Standard way in main script with external UI

(previously generated by QT Designer / Creator)

NEW: MDI (Multi-dialog interface) is supported [inside 2nd comment]

# -*- coding: utf-8 -*-

import sys
from PyQt5.QtWidgets import QApplication, QWidget
from my_app_ui import Ui_Form


class MyWindow(QWidget, Ui_Form):  # Inheritance exactly in this sequence
    def __init__(self, *args, **kwargs):
        super(MyWindow, self).__init__(*args, **kwargs)

        self.setupUi(self)

        # -== Signals ==-
        self.btn_click.clicked.connect(self.click_me)

        self.show()

    # -== event handlers aka Slots ==-
    def click_me(self):
        my_text = self.lineEdit.text()
        self.label.setText(my_text)


if __name__ == "__main__":
    app = QApplication(sys.argv)  # or QApplication([])
    win = MyWindow()
    sys.exit(app.exec())  # or simply app.exec() or app.exec_()
@jigi-33
Copy link
Author

jigi-33 commented Feb 21, 2022

Awesome way to create MDI (multi-dialog interface)
(supported MDI app, QMainWindow-based)

supporting_mdi_app_qmainwindow_based

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment