ComboBox

class ComboBox[source]

Bases: QComboBox

A customizable combo box widget, supporting item-specific rendering with an optional color delegate.

Parameters:
itemslist

List of items to populate the combo box.

change_callbackCallable

Function to execute on value change. Should accept a single argument corresponding to the selected item’s data.

paintbool, optional

Whether to use a custom delegate for item rendering, such as displaying colors. Defaults to None.

Attributes:
paintbool

Flag indicating whether custom item rendering is enabled.

assigned_colorQColor or None

The color assigned to the combo box before any changes.

is_changedbool

Indicates if the color has been changed through user interaction.

Methods

populate(items: list) -> None

Populates the combo box with items.

setAssignedColor(color: QColor) -> None

Sets the assigned color to be displayed when the item is not changed.

on_index_changed(change_callback: Callable, index: int) -> None

Handles the index change event and triggers the callback.

paintEvent(event) -> None

Custom painting for the combo box, used when paint is True.

Methods

on_index_changed

Handles the index change event and triggers the callback.

paintEvent

populate

Populate the combo box with items.

setAssignedColor

Sets the assigned color to be displayed when the item is not changed.

Inherited Methods

acceptDrops

accessibleDescription

accessibleName

actionEvent

actions

activateWindow

addAction

addActions

addItem

addItems

adjustSize

autoFillBackground

backgroundRole

backingStore

baseSize

blockSignals

changeEvent

childAt

childEvent

children

childrenRect

childrenRegion

clear

clearEditText

clearFocus

clearMask

close

closeEvent

colorCount

completer

connect

connectNotify

contentsMargins

contentsRect

contextMenuEvent

contextMenuPolicy

count

create

createWinId

createWindowContainer

currentData

currentIndex

currentText

cursor

customEvent

deleteLater

depth

destroy

devType

devicePixelRatio

devicePixelRatioF

devicePixelRatioFScale

disconnect

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

dropEvent

dumpObjectInfo

dumpObjectTree

duplicatesEnabled

dynamicPropertyNames

effectiveWinId

emit

ensurePolished

enterEvent

event

eventFilter

find

findChild

findChildren

findData

findText

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPolicy

focusPreviousChild

focusProxy

focusWidget

font

fontInfo

fontMetrics

foregroundRole

frameGeometry

frameSize

geometry

grab

grabGesture

grabKeyboard

grabMouse

grabShortcut

graphicsEffect

graphicsProxyWidget

hasFocus

hasFrame

hasHeightForWidth

hasMouseTracking

hasTabletTracking

height

heightForWidth

heightMM

hide

hideEvent

hidePopup

iconSize

inherits

initPainter

initStyleOption

inputMethodEvent

inputMethodHints

inputMethodQuery

insertAction

insertActions

insertItem

insertItems

insertPolicy

insertSeparator

installEventFilter

internalWinId

isActiveWindow

isAncestorOf

isEditable

isEnabled

isEnabledTo

isFullScreen

isHidden

isLeftToRight

isMaximized

isMinimized

isModal

isQuickItemType

isRightToLeft

isSignalConnected

isTopLevel

isVisible

isVisibleTo

isWidgetType

isWindow

isWindowModified

isWindowType

itemData

itemDelegate

itemIcon

itemText

keyPressEvent

keyReleaseEvent

keyboardGrabber

killTimer

layout

layoutDirection

leaveEvent

lineEdit

locale

logicalDpiX

logicalDpiY

lower

mapFrom

mapFromGlobal

mapFromParent

mapTo

mapToGlobal

mapToParent

mask

maxCount

maxVisibleItems

maximumHeight

maximumSize

maximumWidth

metaObject

metric

minimumContentsLength

minimumHeight

minimumSize

minimumSizeHint

minimumWidth

model

modelColumn

mouseDoubleClickEvent

mouseGrabber

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

move

moveEvent

moveToThread

nativeEvent

nativeParentWidget

nextInFocusChain

normalGeometry

objectName

overrideWindowFlags

overrideWindowState

paintEngine

paintingActive

palette

parent

parentWidget

physicalDpiX

physicalDpiY

placeholderText

pos

previousInFocusChain

property

raise_

receivers

rect

redirected

releaseKeyboard

releaseMouse

releaseShortcut

removeAction

removeEventFilter

removeItem

render

repaint

resize

resizeEvent

restoreGeometry

rootModelIndex

saveGeometry

screen

scroll

sender

senderSignalIndex

setAcceptDrops

setAccessibleDescription

setAccessibleName

setAttribute

setAutoFillBackground

setBackgroundRole

setBaseSize

setCompleter

setContentsMargins

setContextMenuPolicy

setCurrentIndex

setCurrentText

setCursor

setDisabled

setDuplicatesEnabled

setEditText

setEditable

setEnabled

setFixedHeight

setFixedSize

setFixedWidth

setFocus

setFocusPolicy

setFocusProxy

setFont

setForegroundRole

setFrame

setGeometry

setGraphicsEffect

setHidden

setIconSize

setInputMethodHints

setInsertPolicy

setItemData

setItemDelegate

setItemIcon

setItemText

setLayout

setLayoutDirection

setLineEdit

setLocale

setMask

setMaxCount

setMaxVisibleItems

setMaximumHeight

setMaximumSize

setMaximumWidth

setMinimumContentsLength

setMinimumHeight

setMinimumSize

setMinimumWidth

setModel

setModelColumn

setMouseTracking

setObjectName

setPalette

setParent

setPlaceholderText

setProperty

setRootModelIndex

setScreen

setShortcutAutoRepeat

setShortcutEnabled

setSizeAdjustPolicy

setSizeIncrement

setSizePolicy

setStatusTip

setStyle

setStyleSheet

setTabOrder

setTabletTracking

setToolTip

setToolTipDuration

setUpdatesEnabled

setValidator

setView

setVisible

setWhatsThis

setWindowFilePath

setWindowFlag

setWindowFlags

setWindowIcon

setWindowIconText

setWindowModality

setWindowModified

setWindowOpacity

setWindowRole

setWindowState

setWindowTitle

sharedPainter

show

showEvent

showFullScreen

showMaximized

showMinimized

showNormal

showPopup

signalsBlocked

size

sizeAdjustPolicy

sizeHint

sizeIncrement

sizePolicy

stackUnder

startTimer

statusTip

style

styleSheet

tabletEvent

testAttribute

thread

timerEvent

toolTip

toolTipDuration

topLevelWidget

tr

underMouse

ungrabGesture

unsetCursor

unsetLayoutDirection

unsetLocale

update

updateGeometry

updateMicroFocus

updatesEnabled

validator

view

visibleRegion

whatsThis

wheelEvent

width

widthMM

winId

window

windowFilePath

windowFlags

windowHandle

windowIcon

windowIconText

windowModality

windowOpacity

windowRole

windowState

windowTitle

windowType

x

y