(self)
#works
        extractAction = QtWidgets.QAction("Action name", self.QObject, checkable=True)
        extractAction.setShortcut("Ctrl+Q")
        extractAction.setStatusTip('Status tip')
        extractAction.triggered.connect(lambda:self.addToolBar('test'))
        extractAction.setCheckable(True)

        mainMenu = self.QObject.menuBar()
        fileMenu = mainMenu.addMenu('&File')
        fileMenu.addSeparator()
        fileMenu.addAction(extractAction)
        fileMenu2 = fileMenu.addMenu('dfa')


        extractAction = QtWidgets.QAction("Action name", fileMenu2, checkable=True)
        extractAction.setShortcut("Ctrl+Q")
        extractAction.setStatusTip('Status tip')
        extractAction.triggered.connect(lambda:self.addToolBar('test'))

        fileMenu2.addAction(extractAction)
#works
        extractAction = QtWidgets.QAction("Action name", self.QObject, checkable=True)
        extractAction.setShortcut("Ctrl+Q")
        extractAction.setStatusTip('Status tip')
        extractAction.triggered.connect(lambda:self.addToolBar('test'))
        extractAction.setCheckable(True)
#works extractAction = QtWidgets . QAction ( Action name self . QObject checkable = True ) extractAction . setShortcut ( Ctrl + Q ) extractAction . setStatusTip ( Status tip ) extractAction . triggered . connect ( lambda : self . addToolBar ( test )) extractAction . setCheckable ( True )
def addMenuItem(self):
        '''
        #works
        extractAction = QtWidgets.QAction("Action name", self.QObject, checkable=True)
        extractAction.setShortcut("Ctrl+Q")
        extractAction.setStatusTip('Status tip')
        extractAction.triggered.connect(lambda:self.addToolBar('test'))
        extractAction.setCheckable(True)

        mainMenu = self.QObject.menuBar()
        fileMenu = mainMenu.addMenu('&File')
        fileMenu.addSeparator()
        fileMenu.addAction(extractAction)
        fileMenu2 = fileMenu.addMenu('dfa')


        extractAction = QtWidgets.QAction("Action name", fileMenu2, checkable=True)
        extractAction.setShortcut("Ctrl+Q")
        extractAction.setStatusTip('Status tip')
        extractAction.triggered.connect(lambda:self.addToolBar('test'))

        fileMenu2.addAction(extractAction)
        '''
        
        '''
        #to do
        with self.addMenu('Menu') as main_menu:
            with main_menu.addMenu('Submenu') as sub_menu
                action = sub_menu.addAction('test action')
                action.setShortcut('Qtrl+Q')
                action.setStatusTip('status tip')
                action.triggered.connect(lambda: None)
            main_menu.addSeparator()
        '''
def addMenuItem ( self ) : '''
        #to do
        with self.addMenu('Menu') as main_menu:
            with main_menu.addMenu('Submenu') as sub_menu
                action = sub_menu.addAction('test action')
                action.setShortcut('Qtrl+Q')
                action.setStatusTip('status tip')
                action.triggered.connect(lambda: None)
            main_menu.addSeparator()
        '''