forked from AG_QGIS/Plugin_SN_Basis
Wrappe modular aufgebaut, Tests erfolgreich, Menüleiste und Werzeugleiste werden eingetragen (QT6 und QT5)- (Es fehlen noch Fachplugins, um zu prüfen, ob es auch wirklich in QGIS geht)
This commit is contained in:
41
functions/dialog_wrapper.py
Normal file
41
functions/dialog_wrapper.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""
|
||||
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
|
||||
Reference in New Issue
Block a user