Advertisement
kingbode

Untitled

Jan 6th, 2024
1,021
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QMenu, QAction
  2. from PyQt5.QtGui import *
  3. import sys
  4.  
  5. class MainWindow(QMainWindow):
  6.     def __init__(self, parent=None):
  7.         super(MainWindow, self).__init__(parent)
  8.         self.setWindowTitle("Welcome to PyQt5")
  9.         self.setStyleSheet("background-color: red;color: white")
  10.  
  11.         # Create menu bar and menus
  12.         menu_bar = self.menuBar()
  13.         file_menu = menu_bar.addMenu("File")
  14.  
  15.         # Add actions to the File menu
  16.         home_action = QAction("Home", self)
  17.         insert_action = QAction("Insert", self)
  18.         view_action = QAction("View", self)
  19.  
  20.         file_menu.addAction(home_action)
  21.         file_menu.addAction(insert_action)
  22.         file_menu.addAction(view_action)
  23.  
  24.         # Create a QLabel
  25.         label = QLabel("Hello World", self)
  26.         self.setCentralWidget(label)
  27.  
  28. def main():
  29.     app = QApplication(sys.argv)
  30.     window = MainWindow()
  31.     window.show()
  32.     sys.exit(app.exec_())
  33.  
  34. if __name__ == '__main__':
  35.     main()
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement