self.action = QAction(self) self.action.setText("Action") self.menubar.addAction(self.action) self.action.triggered.connect(self.function)