TermTk.TTkWidgets.checkbox

TTkCheckbox

class TTkCheckbox(*args, **kwargs)[source]

Checked

[X]CheckBox

Unchecked

[ ]CheckBox

Partially Checked

[/]CheckBox
Demo

formwidgets.py

Parameters
  • text (str, optional) – the text shown on the checkbox, defaults to “”

  • checked (bool, optional) – Checked status, defaults to “False”

Signals

signal clicked(checked)

This signal is emitted when the button is activated

Parameters

checked (bool) – True if checked otherwise False

signal stateChanged(state)

This signal is emitted whenever the checkbox’s state changes, i.e., whenever the user checks or unchecks it.

Parameters

state (CheckState) – state of the checkbox

signal toggled(checked)

This signal is emitted whenever the checkbox’s state changes, i.e., whenever the user checks or unchecks it.

Parameters

checked (bool) – True if checked otherwise False

checkState()[source]

Retrieve the state of the checkbox

Returns

CheckState : the checkbox status

close()
dragEnterEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkDropEvent) – The drop event

Returns

True if the event has been handled

Return type

bool

dragLeaveEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkDropEvent) – The drop event

Returns

True if the event has been handled

Return type

bool

dragMoveEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkDropEvent) – The drop event

Returns

True if the event has been handled

Return type

bool

dropEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkDropEvent) – The drop event

Returns

True if the event has been handled

Return type

bool

enterEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

hide()
isChecked()[source]

This property holds whether the checkbox is checked

Returns

bool - True if Checked or PartiallyChecked

isTristate()[source]

This property holds whether the checkbox is a tri-state checkbox

Returns

bool

keyEvent(evt)[source]

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkKeyEvent) – The keyboard event

Returns

True if the event has been handled

Return type

bool

keyPressEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkKeyEvent) – The keyboard event

Returns

True if the event has been handled

Return type

bool

keyReleaseEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkKeyEvent) – The keyboard event

Returns

True if the event has been handled

Return type

bool

leaveEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

lowerWidget()
mouseDoubleClickEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mouseDragEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mouseEvent(evt)

Caution

Don’t touch this!

mouseMoveEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mousePressEvent(evt)[source]

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mouseReleaseEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mouseTapEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

move(x: int, y: int)

Move the widget

Parameters
  • x (int) – x position

  • y (int) – y position

moveEvent(x: int, y: int)

Event Callback triggered after a successful move

name() str
paintEvent(canvas)[source]

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

raiseWidget(raiseParent=True)
resize(w: int, h: int)

Resize the widget

Parameters
  • w (int) – the new width

  • h (int) – the new height

resizeEvent(w: int, h: int)

Event Callback triggered after a successful resize

setCheckState(state)[source]

Sets the checkbox’s check state.

Parameters

state (CheckState) – state of the checkbox

setChecked(state)[source]

Set the check status

Parameters

state (bool) –

setDisabled(disabled=True)
setEnabled(enabled: bool = True)
setFocus()
setGeometry(x: int, y: int, w: int, h: int)

Resize and move the widget

Parameters
  • x (int) – x position

  • y (int) – y position

  • w (int) – the new width

  • h (int) – the new height

setName(name: str)
setText(text)[source]

This property holds the text shown on the checkhox

Parameters

text (TTkString) –

setTristate(tristate)[source]

Enable/Disable the tristate property

Parameters

tristate (bool) –

setVisible(visible: bool)
show()
text()[source]

This property holds the text shown on the checkhox

Returns

TTkString

wheelEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool