[Python] How to add separator to menuBar in pyqt5

Discussão em 'Python' iniciado por Stack, Abril 16, 2025.

  1. Stack

    Stack Membro Participativo

    main window with menubar ,toolbar and statusbar

    class TajirMWindow(QMainWindow):
    """Main Window."""
    def __init__(self, parent=None):
    """Initializer."""
    super().__init__(parent)
    self.setWindowTitle("Tajir/Home")
    self.resize(800, 400)
    self.centralWidget = QLabel("Hello, World")
    self.centralWidget.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
    self.setCentralWidget(self.centralWidget)
    self._createActions()
    self._connectActions()
    self._createMenuBar() #Menus
    self._createToolBars()#tools
    '''
    Menu Bar function
    '''
    def _createMenuBar():
    menuBar = self.menuBar()
    fileMenu = menuBar.addMenu("&File")
    outilMenu = menuBar.addMenu("&Outils")
    menuBar.addSeparator()
    achatMenu = menuBar.addMenu("Bying")
    stockMenu = menuBar.addMenu("Stocks")
    menuBar.addSeparator()
    helpMenu = menuBar.addMenu("&Help")



    when i run the code no probleme accur but i didn t get the separator

    Continue reading...

Compartilhe esta Página