pyqt5 qmainwindow code example
Example 1: qmainwindow example python
import sys
from PyQt5.QtWidgets import QApplication, QLabel, QMainWindow
from PyQt5.QtCore import Qt
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.setWindowTitle("My Awesome App")
label = QLabel("This is a PyQt5 window!")
label.setAlignment(Qt.AlignCenter)
self.setCentralWidget(label)
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()
Example 2: pyqt5 toolbar
toolbar = self.addToolBar("File")
edit=QAction(QtGui.QIcon("edit.png"),"Edit",self)
saveEdit=QAction(QtGui.QIcon("save.png"),"Save",self)
toolbar.addAction(edit)
toolbar.addAction(edit)