Skip to content

widget_mix

Mihaly Konda edited this page Jul 9, 2025 · 2 revisions

widget_mix

version: v1.0.0

A module for a mix of custom widgets.


class WheelEventFilter(QObject)

Event filter for blocking wheel events, install it on a target widget. The constructor needs a parent so the filter won't get garbage-collected. Needed as focusPolicy is ignored in PySide6 v6.6.2


def eventFilter(self, watched: CustomWidgetT, event: QEvent) -> bool

Overridden event filter method.

Parameters:

  • watched: The watched object.
  • event: The caught event.

class WidgetListWidget(QWidget)

A widget that emulates a QListWidget for QWidgets. (Each contained widget is expected to inherit ListMixin.)


def __init__(self, widgets: list = None) -> None

Initializer for the class.

Parameters:

  • widgets: The list of widgets to add to the list.

def __getitem__(self, index: int) -> CustomWidgetT

Returns the widget from the requested index in the list.

Parameters:

  • index: The index of the widget to return.

def __iter__(self) -> Iterator[CustomWidgetT]

Makes the object iterable, yielding the widgets of the list.


def _setup_ui(self) -> None

Sets up the user interface: GUI objects and layouts.


def _setup_connections(self) -> None

Sets up the connections of the GUI objects.


@property
def widget_count(self) -> int

Returns the number of widgets in the list.


@property
def selection(self) -> int

Returns the selection index or -1 if no widget is selected.


def _update_widget_names(self) -> None

Updates the widgets' objectName by their position in the list.


def list_handler(self, command: str, widget: CustomWidgetT = None) -> bool

Handles list operations (e.g. adding a widget to the list).

Parameters:

  • command: 'a', 'r', 'u', 'd' for adding, removing, moving up or down a widget, respectively. To clear the list, use 'c'.
  • widget: Optional parameter, the widget to be added to the list.

Returns: A success flag.


def _update_selection(self) -> None

Emulates the selection behaviour of a button group.


def _visual_update(self) -> None

Provides visual update to the list widget.


class ListMixin

Mixin class to make a QWidget compatible with the WidgetListWidget. Expects the target widget to use the checkbox named _chkSelection.

Signals:

  • selected: A signal indicating that the course got selected.

def __init__(self) -> None

Initializer for the class.


def _setup_ui(self) -> None

Sets up the user interface: GUI objects and layouts.


def _setup_connections(self) -> None

Sets up the connections of the GUI objects.


def _slot_selected(self) -> None

Emits the selection signal.


@property
def is_selected(self) -> bool

Returns the selection state of the selection checkbox.


def deselect(self) -> None

Deselects the widgets while blocking the corresponding signal.

API reference

Base/technical modules:

Other modules

Clone this wiki locally