Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QMenu, QAction
- from PyQt5.QtGui import *
- import sys
- class MainWindow(QMainWindow):
- def __init__(self, parent=None):
- super(MainWindow, self).__init__(parent)
- self.setWindowTitle("Welcome to PyQt5")
- self.setStyleSheet("background-color: red;color: white")
- # Create menu bar and menus
- menu_bar = self.menuBar()
- file_menu = menu_bar.addMenu("File")
- # Add actions to the File menu
- home_action = QAction("Home", self)
- insert_action = QAction("Insert", self)
- view_action = QAction("View", self)
- file_menu.addAction(home_action)
- file_menu.addAction(insert_action)
- file_menu.addAction(view_action)
- # Create a QLabel
- label = QLabel("Hello World", self)
- self.setCentralWidget(label)
- def main():
- app = QApplication(sys.argv)
- window = MainWindow()
- window.show()
- sys.exit(app.exec_())
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement