GIn GUI application menubar is commonly used. Many commands are placed on the menu bar. ( QMenuBar official document )
In macOS the menu bar works differently; as seen in the below example, adding one more line of code (menubar.setNativeMenuBar(False)) allows the same results to be yielded in macOS.
First, as shown below, save the icon(exit.png) for the menu in the folder.
menuBar() method creates a menu bar. Then make ‘File’ menu and add ‘exitAction’ action to it.
Ampersand(&) of ‘&File’ helps create shortkeys easily. Because there is an ampersand in front of ‘F’, ‘Alt+F’ becomes the shortkey for ‘File’ menu. If you put the ampersand in front of ‘i’, then ‘Alt+I’ becomes the shortkey.