In this tutorial, I am going to show you how to create a combo box widget with PyQt5 in Python.

If you have never used a combo box before, a combo box is just a drop-down with a list of items a user can choose from.

Buy Me a Coffee? Your support is much appreciated!
PayPal Me:
Venmo: @Jie-Jenn

Full code

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QComboBox, QPushButton

class ComboBoxDemo(QWidget):
    def __init__(self):

        lstCompany = ['Google', 'Facebook', 'Microsoft', 'Apple', 'Uber']

        self.comboBox = QComboBox(self)
        self.comboBox.setGeometry(50, 50, 400, 35)

        self.btn = QPushButton('Click', self)
        self.btn.setGeometry(170, 120, 120, 35)

    def getComboValue(self):
        print((self.comboBox.currentText(), self.comboBox.currentIndex()))

app = QApplication(sys.argv)

demo = ComboBoxDemo()