I want to create a nested menu with three levels File->Circuit->then with an option of Full of half with the later options checkable and exclusive. I have achieved this with respect to the items being checkable though not exclusive.
Initially I used this example (One QAction checkable at time in QMenu) to setExclusive in a group though I could not add another nested group level. I can set the File -> then Circuit selection but not the full or half selection, so is the reason I chose the method below to set the number of menu levels.
import sys
from PyQt5.QtWidgets import QMainWindow, QAction, QMenu, QApplication
class Example(QMainWindow):
def __init__(self):
super().__init__()
self.menubar = self.menuBar()
self.fileMenu = self.menubar.addMenu('File')
self.impMenu = QMenu('Circuit', self)
self.impAct0 = QAction('Half Bridge', self, checkable=True, checked=True)
self.impAct1 = QAction('Full Bridge', self, checkable=True, checked=False)
self.impMenu.addAction(self.impAct0)
self.impMenu.addAction(self.impAct1)
self.fileMenu.addMenu(self.impMenu)
self.setGeometry(300, 300, 300, 200)
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())