A menubar can be added to a PyQt window. Its a horizontal bar with buttons items, typically file menu and others.
This example adds a menubar and textbox to a PyQt window. As shown in the screenshot below.
Related Course: Create GUI Apps with Python PyQt5
PyQt Menubar
Menubar example
A menubar can be constructed with QMenuBar()
. You can add menus like so .addMenu("File")
. Then add actions to the menu so .addAction("Open")
.
The menubar has to be added to a layout, which is done with this line layout.addWidget(menubar, 0, 0)
.
1 | from PyQt5.QtCore import * |
If you are new to Python PyQt, then I highly recommend this book.