PyQt windows often have a toolbar QToolBar
, besides a file menu. The toolbar contains some buttons. In a web browser those buttons may be back, forward, refresh, home. In a text editor open, save and so on.
In this article you’ll learn how to add a toolbar to your window.
Related Course: Create GUI Apps with Python PyQt5
Toolbar
QToolBar example
The program below creates a window with a toolbar QToolBar
with buttons QToolButton
. You can add a toolbar to any PyQt window. It also adds textbox.
The toolbar is added to a layout QGridLayout
and the buttons QToolButton
to the QToolBar
.
1 | from PyQt5.QtWidgets import * |
If you are new to Python PyQt, then I highly recommend this book.