Toolbox is a container. It can show groups of items separated by tabs. If there are to many items for a toolbar, you may want a toolbox.

A screenshot of a toolbox QToolBox is shown below.

toolbox pyqt qtoolbox

Related Course:
PyQt Desktop Apps with Python
icon

Toolbox example

QToolBox

The code below creates a toolbox with 3 items. The toolbox QToolBox has a method .addItem().

The toolbox itself has to be added to a layout, for instance layout.addWidget(toolbox, 0, 0).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from PyQt5.QtWidgets import *
import sys

class Window(QWidget):

def __init__(self):
QWidget.__init__(self)
layout = QGridLayout()
self.setLayout(layout)

# Add toolbar and items
toolbox = QToolBox()
layout.addWidget(toolbox, 0, 0)
label = QLabel()
toolbox.addItem(label, "Students")
label = QLabel()
toolbox.addItem(label, "Teachers")
label = QLabel()
toolbox.addItem(label, "Directors")

app = QApplication(sys.argv)
screen = Window()
screen.show()
sys.exit(app.exec_())

Download Examples