hamyar_paygah.utils.qt_utils

Utility functions related to Qt UI.

Attributes

NOT_REGISTERED_PERSIAN_TEXT

Text to show when an information is not yet registered by EMS

F

Functions

set_checkbox(checkbox, *, value)

Set a checkbox state and enabled status.

set_textfield(textfield, value)

Set a text field with a value or disable it if empty/zero.

set_enum_textfield(textfield, enum_value)

Set a QLineEdit with the Persian label of a domain enum.

typed_async_slot(*args, **kwargs)

Typed wrapper around qasync.asyncSlot.

show_error_dialog(parent, title, message)

Display an error dialog with a critical icon.

Module Contents

hamyar_paygah.utils.qt_utils.NOT_REGISTERED_PERSIAN_TEXT: str = 'ثبت نشده'

Text to show when an information is not yet registered by EMS

hamyar_paygah.utils.qt_utils.set_checkbox(checkbox, *, value)

Set a checkbox state and enabled status.

The checkbox is checked and enabled if value is True. If value is False, the checkbox is unchecked and disabled.

Parameters:
  • checkbox (PySide6.QtWidgets.QCheckBox) – The QCheckBox instance to modify.

  • value (bool) – Determines both the checked state and whether the checkbox is enabled.

Return type:

None

hamyar_paygah.utils.qt_utils.set_textfield(textfield, value)

Set a text field with a value or disable it if empty/zero.

This function updates the text of a QLineEdit or QPlainTextEdit widget. - If value is None or zero (for integers), the field is disabled and filled with a placeholder text (NOT_REGISTERED_PERSIAN_TEXT). - Otherwise, the field is updated with str(value) and will be enabled.

Parameters:
Returns:

None

Return type:

None

Notes

  • This function is designed to handle various types safely.

  • NOT_REGISTERED_PERSIAN_TEXT is used as a placeholder for missing values.

hamyar_paygah.utils.qt_utils.set_enum_textfield(textfield, enum_value)

Set a QLineEdit with the Persian label of a domain enum.

If enum_value is None, the text field is populated with NOT_REGISTERED_PERSIAN_TEXT and disabled.

If a valid enum value is provided, its persian_label attribute is displayed and the field is enabled.

Parameters:
Returns:

None

Return type:

None

hamyar_paygah.utils.qt_utils.F
hamyar_paygah.utils.qt_utils.typed_async_slot(*args, **kwargs)

Typed wrapper around qasync.asyncSlot.

Provides proper type hints for the untyped asyncSlot decorator from the qasync module. This allows static type checkers such as mypy or Pyright to correctly infer the signature of decorated async functions.

Parameters:
  • *args (Any) – Positional arguments forwarded to asyncSlot.

  • **kwargs (Any) – Keyword arguments forwarded to asyncSlot.

Returns:

A decorator that preserves the type signature of the async function it decorates.

Return type:

collections.abc.Callable[[F], F]

hamyar_paygah.utils.qt_utils.show_error_dialog(parent, title, message)

Display an error dialog with a critical icon.

This function creates a modal error dialog attached to the given parent widget. The dialog displays a title and a message to inform the user of an error. Execution is blocked until the user closes the dialog.

Parameters:
  • parent (PySide6.QtWidgets.QWidget) – The parent widget for the dialog. The dialog will be centered on this widget.

  • title (str) – The title displayed in the window’s title bar.

  • message (str) – The error message to display in the dialog body.

Returns:

None

Return type:

None

Notes

  • This function uses a modal dialog; it will block interaction with other windows until closed.

  • For non-blocking dialogs, consider using dialog.show() instead of dialog.exec().