qmainwindow example python

Solutions on MaxInterview for qmainwindow example python by the best coders in the world

showing results for - "qmainwindow example python"
Jude
08 Oct 2017
1import sys
2from PyQt5.QtWidgets import QApplication, QLabel, QMainWindow
3from PyQt5.QtCore import Qt
4
5# Subclass QMainWindow to customise your application's main window
6class MainWindow(QMainWindow):
7
8    def __init__(self, *args, **kwargs):
9        super(MainWindow, self).__init__(*args, **kwargs)
10
11        self.setWindowTitle("My Awesome App")
12
13        label = QLabel("This is a PyQt5 window!")
14
15        # The `Qt` namespace has a lot of attributes to customise
16        # widgets. See: http://doc.qt.io/qt-5/qt.html
17        label.setAlignment(Qt.AlignCenter)
18
19        # Set the central widget of the Window. Widget will expand
20        # to take up all the space in the window by default.
21        self.setCentralWidget(label)
22
23
24app = QApplication(sys.argv)
25
26window = MainWindow()
27window.show()
28
29app.exec_()