Creating a Menu Bar and Adding Actions
Understand how we create a menu bar for our GUI applications.
We'll cover the following
Menu bars for our applications
These are the steps we use while creating menus with PyQt:
Creating the main window with the
QMainWindow
class.Making
QMenubar
andQMenu
objects.Using the
QAction
category to add actions to menus.Configuring
QStatusBar
to display information about activities in the status bar.Creating detachable widgets with
QDockWidget
to hold an application's tools.Understanding how to make checkable menu items and submenus.
Additional ideas and tools discussed include:
Using
QIcon
to set and modify icons on widgets and in the main window.New sorts of dialogs, such as the "About" dialog box in
QMessageBox
and theQInputDialog
,QColorDialog
, andQFontDialog
.Using the
QPixmap
andQTransform
classes to manage and modify images.QPrinter
andQPainter
image printing techniques.
Creating the menu
You may access the file menu from the menu bar at the top of the window. It would help if you constructed an instance of the QMenuBar
class, which we developed, to create a menu bar.
Get hands-on with 1400+ tech skills courses.