mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-10 11:04:15 +02:00
example button for the upgrade confirmation dialog
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from typing import List
|
||||
|
||||
from PyQt5.QtGui import QIcon
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
from PyQt5.QtWidgets import QMessageBox, QLabel, QWidget, QHBoxLayout
|
||||
from bauh_api.abstract.view import MessageType
|
||||
|
||||
from bauh.core import resource
|
||||
@@ -23,13 +25,22 @@ def show_message(title: str, body: str, type_: MessageType, icon: QIcon = QIcon(
|
||||
popup.exec_()
|
||||
|
||||
|
||||
def ask_confirmation(title: str, body: str, locale_keys: dict, icon: QIcon = QIcon(resource.get_path('img/logo.svg'))):
|
||||
def ask_confirmation(title: str, body: str, locale_keys: dict, icon: QIcon = QIcon(resource.get_path('img/logo.svg')), widgets: List[QWidget] = None):
|
||||
dialog_confirmation = QMessageBox()
|
||||
dialog_confirmation.setIcon(QMessageBox.Question)
|
||||
dialog_confirmation.setWindowTitle(title)
|
||||
dialog_confirmation.setText(body)
|
||||
dialog_confirmation.setStyleSheet('QLabel { margin-right: 25px; }')
|
||||
|
||||
wbody = QWidget()
|
||||
wbody.setLayout(QHBoxLayout())
|
||||
wbody.layout().addWidget(QLabel(body))
|
||||
|
||||
if widgets:
|
||||
for w in widgets:
|
||||
wbody.layout().addWidget(w)
|
||||
|
||||
dialog_confirmation.layout().addWidget(wbody, 0, 1)
|
||||
|
||||
bt_yes = dialog_confirmation.addButton(locale_keys['popup.button.yes'], QMessageBox.YesRole)
|
||||
dialog_confirmation.addButton(locale_keys['popup.button.no'], QMessageBox.NoRole)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user