Files
Plugin_SN_Basis/functions/dialog_wrapper.py

42 lines
880 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
sn_basis/functions/dialog_wrapper.py Benutzer-Dialoge
"""
from typing import Any
from sn_basis.functions.qt_wrapper import (
QMessageBox,
YES,
NO,
)
# ---------------------------------------------------------
# Öffentliche API
# ---------------------------------------------------------
def ask_yes_no(
title: str,
message: str,
default: bool = False,
parent: Any = None,
) -> bool:
"""
Fragt den Benutzer eine Ja/Nein-Frage.
- In Qt: zeigt einen QMessageBox-Dialog
- Im Mock-Modus: gibt den Default-Wert zurück
"""
try:
buttons = QMessageBox.Yes | QMessageBox.No
result = QMessageBox.question(
parent,
title,
message,
buttons,
YES if default else NO,
)
return result == YES
except Exception:
return default