Skip to content

Commit

Permalink
Added notes on thread safety
Browse files Browse the repository at this point in the history
  • Loading branch information
SaschaCowley committed Dec 18, 2024
1 parent f52a07e commit f437723
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions projectDocs/dev/developerGuide/developerGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1666,8 +1666,9 @@ If none of the standard `ReturnCode` values are suitable for your button, you ma

The `MessageDialog` class also provides a number of convenience methods for showing common types of modal dialogs.
Each of them requires a message string, and optionally a title string and parent window.
They all also support overriding the labels on their buttons.
The following convenience class methods are provided:
They all also support overriding the labels on their buttons via keyword arguments.
They are all thread safe.
The following convenience class methods are provided (keyword arguments for overriding button labels indicated in parentheses):

| Method | Buttons | Return values |
|---|---|---|
Expand Down
8 changes: 8 additions & 0 deletions source/gui/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ class MessageDialog(DpiScalingHelperMixinWithoutInit, wx.Dialog, metaclass=SIPAB
Mixing and matching both patterns is also allowed.
When subclassing this class, you can override `_addButtons` and `_addContents` to insert custom buttons or contents that you want your subclass to always have.
.. warning:: Unless noted otherwise, the message dialog API is **not** thread safe.
"""

_instances: deque["MessageDialog"] = deque()
Expand Down Expand Up @@ -782,6 +784,8 @@ def alert(
):
"""Display a blocking dialog with an OK button.
.. note:: This method is thread safe.
:param message: The message to be displayed in the alert dialog.
:param caption: The caption of the alert dialog, defaults to wx.MessageBoxCaptionStr.
:param parent: The parent window of the alert dialog, defaults to None.
Expand All @@ -808,6 +812,8 @@ def confirm(
) -> Literal[ReturnCode.OK, ReturnCode.CANCEL]:
"""Display a confirmation dialog with OK and Cancel buttons.
.. note:: This method is thread safe.
:param message: The message to be displayed in the dialog.
:param caption: The caption of the dialog window, defaults to wx.MessageBoxCaptionStr.
:param parent: The parent window for the dialog, defaults to None.
Expand Down Expand Up @@ -838,6 +844,8 @@ def ask(
) -> Literal[ReturnCode.YES, ReturnCode.NO, ReturnCode.CANCEL]:
"""Display a query dialog with Yes, No, and Cancel buttons.
.. note:: This method is thread safe.
:param message: The message to be displayed in the dialog.
:param caption: The title of the dialog window, defaults to wx.MessageBoxCaptionStr.
:param parent: The parent window for the dialog, defaults to None.
Expand Down

0 comments on commit f437723

Please sign in to comment.