mad_gui.components.dialogs.UserInformation#

class mad_gui.components.dialogs.UserInformation[source]#

Bases: QDialog

A dialog to transport information to/from user.

Methods

inform(text[, help_link])

Send a message to the user in a pop-up window with an OK-Button.

confirm(text[, help_link])

Ask the user something and obtain yes or no as answer.

classmethod confirm(text: str, help_link: str | None = None) bool[source]#

Ask the user something and obtain yes or no as answer.

Parameters:
text

The question you want to pose to the user.

help_link

If you pass this, it will hide behind the Learn More button in the lower part of the message.

Returns:
answer

Either Yes or No of the class QMessageBox. :py:

Examples

Note: If you want to execute the following example without having a MaD GUI instance running (i.e. you did not use mad_gui.start_gui(), you need to:

>>> from PySide2.QtWidgets import QApplication
>>> app = QApplication()

You do not need the above code snippet, if you want to implement the lines below into your plugin.

>>> from PySide2.QtWidgets import QMessageBox
>>> from mad_gui.components.dialogs import UserInformation
>>> answer = UserInformation.confirm("Do you want to perform X?")
>>> if answer == QMessageBox.Yes:
...    print("Yes!")
...
Yes!
classmethod inform(text: str, help_link: str | None = None) bool[source]#

Send a message to the user in a pop-up window with an OK-Button.

For example this might be useful if something crashed during loading data or executing an algoritihm and you would like to provide more context to the user.

Parameters:
text

The information you want to give to the user.

help_link

If you pass this, it will hide behind the Learn More button in the lower part of the message.

Examples

Note: If you want to execute the following example without having a MaD GUI instance running (i.e. you did not use mad_gui.start_gui(), you need to:

>>> from PySide2.QtWidgets import QApplication
>>> app = QApplication()

You do not need the above code snippet, if you want to implement the lines below into your plugin.

>>> from mad_gui.components.dialogs import UserInformation
>>> UserInformation.inform("Please make sure to X")