Skip to content

message

Mihaly Konda edited this page Nov 12, 2025 · 2 revisions

message

version: v1.0.5

object MessageBoxType [src]

Singleton object of the type _MessageBoxType, containing the types defined in the source JSON file.


function get_messagebox_types() [src]

def get_messagebox_types(fetch_data: bool = False) -> list[str | _MessageBoxData]

Returns the available messagebox types.

Parameters:

  • fetch_data: A flag requesting the _MessageBoxData objects themselves. The default is False.

function merge_json() [src]

def merge_json(path: str) -> None

Takes an external JSON messagebox type file and merges its contents to the package's own file. This way if you create messageboxes you can reuse them in another project.

Parameters:

  • path: Path to the external JSON messagebox type file.

dataclass _MessageBoxData [src]

Settings defining the appearance of a QMessageBox.

Parameters:

  • icon: The icon to set for the message box.
  • title: The title to set for the message box window.
  • text: The text content to set for the message box.
  • buttons: A list of standard buttons to set for the message box.
  • flags: A list of flags to set for the message box defining its behaviour.

[src]

def __post_init__(self) -> None

Adds the correct default values where they are mutable.


[src]

def __eq__(self, other) -> bool

Custom comparison rule, comparing each field.


[src]

def merged_bits(self, attr: str) -> QMessageBox.StandardButton | Qt.WindowType

Merges the bits of either buttons or flags and returns.

Parameters:

  • attr: The requested attribute (buttons or flags) as a string.

Returns: An Enum subclass (concrete type based on attr) with the merged value.


[src]

@property
def as_dict(self) -> dict

Returns the data content as a dictionary.


[src]

@classmethod
def from_dict(cls, src: dict) -> _MessageBoxData

Returns an instance built from a dictionary.

Parameters:

  • src: A dictionary containing data to build an instance, extracted from the handled JSON file.

dataclass _MessageBoxCategories(metaclass=Singleton) [src]

A constant dataclass for holding parameters of the four basic categories of message boxes and an additional custom type. (It's not an Enum-subclass because the fields are mutable.)


[src]

def __post_init__(self) -> None

Creates mutable values after initialization.


class _MessageBoxType(metaclass=Singleton) [src]

A collection of predefined types of messagebox.

[src]

def __init__(self) -> None

Initializer for the class.


[src]

def __getattr__(self, name: str) -> Any

Handles an attribute access request.

Parameters:

  • name: The name of the requested attribute.

Returns: A stored _MessageBoxData object or an attribute of the internal dictionary.


[src]

def __setattr__(self, key: str, value: _MessageBoxData | None) -> None

Handles an attribute setting request.

Parameters:

  • key: The name of the attribute whose value is to be set.
  • value: The value to set for the attribute.

[src]

def __setitem__(self, key: str, value: _MessageBoxData) -> None

Sets a new set of message box data for the internal dictionary by accessing with '[]'.

Parameters:

  • key: The type ID to set the data to.
  • value: The message box data to set.

[src]

def __delitem__(self, key: str) -> None

Deletes a set of message box data from the internal dictionary.


[src]

def import_types(self) -> None

Imports types from the handled JSON file.


[src]

def export_types(self) -> None

Exports types to the handled JSON file.


[src]

def is_empty(self) -> bool

Returns True if there are no defined types, False if there are.


[src]

def converted_keys(self) -> list[str]

Returns the keys converted to a list of space-separated and capitalized strings.


class _OrderedSelectionList(QWidget) [src]

A widget where an ordered selection can be made from a combobox.


[src]

def __init__(self, list_name: str, items: list, add: str, remove: str) -> None

Initializer for the class.

Parameters:

  • list_name: String identifier of the list set to a label.
  • items: A list of items to set for the combobox.
  • add: Text to set for the add button.
  • remove: Text to set for the remove button.

[src]

def _setup_ui(self) -> None

Sets up the user interface: GUI objects and layouts.


[src]

def _setup_connections(self) -> None

Sets up the connections of the GUI objects.


[src]

def _slot_add_item(self) -> None

Adds the current item of the combobox to the selection list.


[src]

def _slot_remove_item(self) -> None

Removes the currently selected item from the selection list.


[src]

def set_selection(self, new_selection: list[str]) -> None

Resets the selection list by the provided items.

Parameters:

  • new_selection: The new items to set to the selection list.

[src]

@property
def selection_str(self) -> list[str]

Returns the string content of the selection list.


[src]

@property
def selection_idx(self) -> list[int]

Returns the selection list encoded by the order of the source item list.


[src]

def setEnabled(self, new_state: bool) -> None

Sets the enabled state of the child widgets.

Parameters:

  • new_state: The new enabled state to set.

class _MessageBoxTypeCreator(QDialog) [src]

A dialog for defining custom messagebox types / editing existing ones.


[src]

def __init__(self) -> None

Initializer for the class.


[src]

def _setup_ui(self) -> None

Sets up the user interface: GUI objects and layouts.


[src]

def _setup_connections(self) -> None

Sets up the connections of the GUI objects.


[src]

def _slot_set_control_states(self) -> None

Updates the controls' enabled state based on the state of the checkbox.


[src]

def _slot_update_by_combobox(self) -> None

Updates the dialog according to the controlling combobox.


[src]

def _get_as_messageboxdata(self) -> _MessageBoxData

Returns a MessageBoxData object built from the settings made in the dialog.


[src]

def _slot_test_settings(self) -> None

Creates a message box dialog based on the settings.


[src]

def _slot_export_settings(self) -> None

Exports the currently set type and updates the dialog accordingly.


[src]

def _slot_delete_settings(self) -> None

Deletes the currently selected type and updates the dialog accordingly.


function message() [src]

def message(parent: QWidget, mbd: _MessageBoxData, custom_text: str = None) -> QMessageBox.StandardButton

Shows a modal QMessageBox with preset content (or custom text) and a custom theme.

Parameters:

  • parent: The parent widget calling for the message dialog.
  • mbd: MessageBox data to define the appearance of the created window.
  • custom_text: Overrides the preset text. The default is None, having no effect.

Returns: The clicked standard button (or its equal if the dialog was just closed).


function write_stub() [src]

def write_stub() -> None

Writes the stub file to the project directory if it doesn't exist already or if an external stub file directory is set it creates a new stub file there (and deletes the package's own) or overrides the existing one.

API reference

Base/technical modules:

Other modules

Clone this wiki locally