example button for the upgrade confirmation dialog

This commit is contained in:
Vinicius Moreira
2019-08-28 22:06:20 -03:00
parent 8d030fc7b9
commit a0a93ce62f
3 changed files with 24 additions and 9 deletions

View File

@@ -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)