TTkComboBox🌶️

class TTkComboBox(*, list: List[str] | None = None, index: int = -1, insertPolicy: InsertPolicy = InsertPolicy.InsertAtBottom, textAlign: Alignment = Alignment.CENTER_ALIGN, editable: bool = False, **kwargs)[source]🌶️

Bases: TTkContainer

TTkComboBox:

editable = False

[ - select -  ^]

editable = True

[ Text       [^]
Parameters:
  • list (list[str], optional) – the list of the items selectable by this combobox, defaults to []

  • index (int, optional) – the initial selected index, defaults to -1 (no selection)

  • insertPolicy (TTkK.InsertPolicy, optional) – the policy used to determine where user-inserted items should appear in the combobox, defaults to TTkK.InsertPolicy.InsertAtBottom

  • textAlign (TTkK.Alignment, optional) – the text alignment for the displayed text, defaults to TTkK.Alignment.CENTER_ALIGN

  • editable (bool, optional) – whether the combo box can be edited by the user, defaults to False

TTkContainer’s inherited init params:

Parameters:
  • layout (TermTk.TTkLayouts) – the layout of this widget, optional, defaults to TTkLayout

  • padding (TTkPadding) – the padding (top, bottom, left, right) of the widget, defaults to (0,0,0,0)

  • paddingTop (int) – the Top padding, override Top padding if already defined, optional, default=0 if padding is not defined

  • paddingBottom (int) – the Bottom padding, override Bottom padding if already defined, optional, default=0 if padding is not defined

  • paddingLeft (int) – the Left padding, override Left padding if already defined, optional, default=0 if padding is not defined

  • paddingRight (int) – the Right padding, override Right padding if already defined, optional, default=0 if padding is not defined

  • forwardStyle (bool) – [Experimental] any change of style will reflect the children, defaults to False

TTkWidget’s inherited init params:

Parameters:
  • name (str, optional) – the name of the widget, defaults to “”

  • parent (TTkWidget, optional) – the parent widget, defaults to None

  • x (int, optional) – the x position, defaults to 0

  • y (int, optional) – the y position, defaults to 0

  • pos ((int,int), optional) – the [x,y] position (override the previously defined x, y), defaults to (x,y)

  • width (int, optional) – the width of the widget, defaults to 0

  • height (int, optional) – the height of the widget, defaults to 0

  • size ((int,int), optional) – the size [width, height] of the widget (override the previously defined sizes), defaults to (width,height)

  • maxWidth (int, optional) – the maxWidth of the widget, defaults to 0x10000

  • maxHeight (int, optional) – the maxHeight of the widget, defaults to 0x10000

  • maxSize ((int,int), optional) – the max [width,height] of the widget, optional, defaults to (maxWidth,maxHeight)

  • minWidth (int, optional) – the minWidth of the widget, defaults to 0

  • minHeight (int, optional) – the minHeight of the widget, defaults to 0

  • minSize ((int,int), optional) – the minSize [width,height] of the widget, optional, defaults to (minWidth,minHeight)

  • toolTip (TTkString, optional) – This property holds the widget’s tooltip, defaults to ‘’

  • style (dict, optional) – this field hold the custom style to be used by this widget

  • addStyle (dict, optional) – this field is required to override/merge the new style on top of the current one, useful if only few params need to be changed

  • visible (bool, optional) – the visibility, optional, defaults to True

  • enabled (bool, optional) – the ability to handle input events, optional, defaults to True

TMouseEvents’s inherited init params:

Initialize self. See help(type(self)) for accurate signature.

TDragEvents’s inherited init params:

Initialize self. See help(type(self)) for accurate signature.

Style🌶️

classStyle = {
            'default':     {'color': TTkColor.fg("#dddd88")+TTkColor.bg("#222222"),
                            'borderColor':TTkColor.RST},
            'disabled':    {'color': TTkColor.fg('#888888'),
                            'borderColor':TTkColor.fg('#888888')},
            'focus':       {'color': TTkColor.fg("#ffff88")+TTkColor.bg("#222222"),
                            'borderColor': TTkColor.fg("#ffff00") + TTkColor.BOLD},
        }

Signals🌶️

closed

This signal is emitted whenever the widget is closed

currentIndexChanged

This signal is emitted when the index in the combobox changes either through user interaction or programmatically.

currentStyleChanged

This signal is emitted whenever the widget stye change

currentTextChanged

This signal is emitted when the text of the current item changes.

editTextChanged

This signal is emitted when the text in the combobox's line edit widget is changed.

focusChanged

This signal is emitted whenever the focus status change i.e. with the setFocus() or clearFocus() methods.

sizeChanged

This signal is emitted whenever the widget size change

Slots🌶️

setCurrentIndex(index)

Set the selected index

setCurrentText(text)

Set the selected Text

setEditText(text)

Set the text in the TTkLineEdit widget

Slots Inherited from: TTkContainer

hide()

hide the widget

show()

show the widget

Slots Inherited from: TTkWidget

close()

Close (Destroy/Remove) the widget

hide()

hide the widget

lowerWidget()

Lower the Widget below its relatives

raiseWidget([raiseParent])

Raise the Widget above its relatives

setDisabled([disabled])

This property holds whether the widget is disnabled

setEnabled([enabled])

This property holds whether the widget is enabled

setFocus()

Focus the widget

setVisible(visible)

Set the visibility status of this widget

show()

show the widget

update([repaint, updateLayout, updateParent])

Notify the drawing routine that the widget changed and needs to draw its new content.

Members🌶️

closed: pyTTkSignal🌶️

This signal is emitted whenever the widget is closed

Parameters:

widget (TTkWidget) – the widget closed (=self)

currentIndexChanged: pyTTkSignal🌶️

This signal is emitted when the index in the combobox changes either through user interaction or programmatically.

Parameters:

index (int) – the new current index

currentStyleChanged: pyTTkSignal🌶️

This signal is emitted whenever the widget stye change

Parameters:

style (dict) – the new style applied

currentTextChanged: pyTTkSignal🌶️

This signal is emitted when the text of the current item changes. The text is passed as parameter.

Parameters:

text (str) – the new current text

editTextChanged: pyTTkSignal🌶️

This signal is emitted when the text in the combobox’s line edit widget is changed. This signal is only emitted when the combobox is editable.

Parameters:

text (str) – the new text in the line edit

focusChanged: pyTTkSignal🌶️

This signal is emitted whenever the focus status change i.e. with the setFocus() or clearFocus() methods

Parameters:

status (bool) – the curent focus status

sizeChanged: pyTTkSignal🌶️

This signal is emitted whenever the widget size change

Parameters:
  • width (int) – the new widget width

  • height (int) – the new widget height

Methods🌶️

addItem(text: str)[source]🌶️

Adds an item to the combobox with the given text.

The item is appended to the list of existing items.

Parameters:

text (str) – the text of the item to add

addItems(items: list[str]) None[source]🌶️

Adds a list of items to the combobox with the given text.

The items are appended to the list of existing items.

Parameters:

items (list[str])

clear() None[source]🌶️

Remove all the items.

currentIndex() int[source]🌶️

Return the current selected index.

Returns:

the current index, -1 if no selection

Return type:

int

currentText() str[source]🌶️

Returns the selected text

Returns:

the current text

Return type:

str

insertPolicy() InsertPolicy[source]🌶️

Retrieve the insert policy used when a new item is added if the combobox editable flag is true.

Returns:

the current insert policy

Return type:

TTkK.InsertPolicy

isEditable() bool[source]🌶️

This tells if an editable TTkLineEdit exists within this widget or not.

Returns:

True if editable, False otherwise

Return type:

bool

lineEdit() TTkLineEdit | None[source]🌶️

Returns the TTkLineEdit widget used if the editable flag is enabled

Returns:

the line edit if available, None otherwise

Return type:

TTkLineEdit | None

setCurrentIndex(index: int) None[source]🌶️

Set the selected index

Parameters:

index (int)

setCurrentText(text: str) None[source]🌶️

Set the selected Text

Parameters:

text (str)

setEditText(text) None[source]🌶️

Set the text in the TTkLineEdit widget

Parameters:

text (str, TTkString) – the text to set (str or TTkString)

setEditable(editable: bool) None[source]🌶️

Create or destroy the editable TTkLineEdit inside this widget.

Parameters:

editable (bool)

setInsertPolicy(policy: InsertPolicy) None[source]🌶️

Define the insert policy used when a new item is inserted when the widget is editable.

Parameters:

policy (TTkK.InsertPolicy)

setTextAlign(align: Alignment) None[source]🌶️

This property holds the displayed text alignment

Parameters:

align (TTkK.Alignment)

textAlign() Alignment[source]🌶️

This property holds the displayed text alignment

Returns:

the current text alignment

Return type:

TTkK.Alignment

Methods Inherited from: TTkContainer

addWidget(widget)

getPadding()

Retrieve the TTkContainer's paddings sizes as shown in Layout Topology

getWidgetByName(name)

Return the widget from its name.

hide()

hide the widget

keyEvent(evt)

This event handler, can be reimplemented in a subclass to receive key events for the widget.

layout()

Get the Layout

maximumHeight()

maximumWidth()

minimumHeight()

minimumWidth()

paintChildCanvas()

removeWidget(widget)

rootLayout()

This is a root layout mainly used to place items that are not supposed to be inside the main layout (i.e. the menu elements).

setCurrentStyle(*args, **kwargs)

setLayout(layout)

Set the Layout used by this widget to place all the child widgets.

setPadding(top, bottom, left, right)

Set the TTkContainer's paddings sizes as shown in Layout Topology

show()

show the widget

update([repaint, updateLayout, updateParent])

Notify the drawing routine that the widget changed and needs to draw its new content.

Methods Inherited from: TTkWidget

clearFocus()

Remove the Focus state of this widget

close()

Close (Destroy/Remove) the widget

currentStyle()

disableWidgetCursor([disable])

enableWidgetCursor([enable])

focusInEvent()

focusOutEvent()

focusPolicy()

geometry()

getCanvas()

getPixmap()

Convenience function which return a pixmap representing the current widget status

getWidgetByName(name)

Return the widget from its name.

hasFocus()

This property holds the focus status of this widget

height()

hide()

hide the widget

isEnabled()

This property holds whether the widget is enabled

isEntered()

isVisible()

Retrieve the visibility status of this widget

isVisibleAndParent()

lowerWidget()

Lower the Widget below its relatives

maxDimension(orientation)

maximumHeight()

maximumSize()

maximumWidth()

mergeStyle(style)

minDimension(orientation)

minimumHeight()

minimumSize()

minimumWidth()

mouseEvent(evt)

move(x, y)

Move the widget

moveEvent(x, y)

Convenience function, Event Callback triggered after a successful move

name()

paintChildCanvas()

paintEvent(canvas)

Paint Event callback, this need to be overridden in the widget.

parentWidget()

pasteEvent(txt)

Callback triggered when a paste event is forwarded to this widget.

pos()

raiseWidget([raiseParent])

Raise the Widget above its relatives

resize(width, height)

Resize the widget

resizeEvent(width, height)

Convenience function, Event Callback triggered after a successful resize

setCurrentStyle(*args, **kwargs)

setDefaultSize(arg, width, height)

setDisabled([disabled])

This property holds whether the widget is disnabled

setDropEventProxy(proxy)

setEnabled([enabled])

This property holds whether the widget is enabled

setFocus()

Focus the widget

setFocusPolicy(policy)

This property holds the way the widget accepts keyboard focus

setGeometry(x, y, width, height)

Resize and move the widget

setMaximumHeight(maxh)

setMaximumSize(maxw, maxh)

setMaximumWidth(maxw)

setMinimumHeight(minh)

setMinimumSize(minw, minh)

setMinimumWidth(minw)

setName(name)

Set the name of this Instance

setParent(parent)

setStyle([style])

setToolTip(toolTip)

setVisible(visible)

Set the visibility status of this widget

setWidgetCursor([pos, type])

show()

show the widget

size()

style()

toolTip()

update([repaint, updateLayout, updateParent])

Notify the drawing routine that the widget changed and needs to draw its new content.

widgetItem()

width()

x()

y()

Methods Inherited from: TMouseEvents

enterEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse enter events for the widget.

leaveEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse leave events for the widget.

mouseDoubleClickEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse click events for the widget.

mouseDragEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse drag events for the widget.

mouseMoveEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse move events for the widget.

mousePressEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse press events for the widget.

mouseReleaseEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse release events for the widget.

mouseTapEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse click events for the widget.

wheelEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse wheel events for the widget.

Methods Inherited from: TKeyEvents

keyEvent(evt)

This event handler, can be reimplemented in a subclass to receive key events for the widget.

Methods Inherited from: TDragEvents

dragEnterEvent(evt)

This event handler, can be reimplemented in a subclass to receive drag events for the widget.

dragLeaveEvent(evt)

This event handler, can be reimplemented in a subclass to receive drag events for the widget.

dragMoveEvent(evt)

This event handler, can be reimplemented in a subclass to receive drag events for the widget.

dropEvent(evt)

This event handler, can be reimplemented in a subclass to receive drag events for the widget.

TTkComboBox Attributes🌶️

classStyle