confimration close
This commit is contained in:
parent
5853d59b02
commit
25b6ac06ae
@ -1,4 +1,4 @@
|
|||||||
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy, QPushButton
|
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy, QPushButton, QMessageBox
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
import glob
|
import glob
|
||||||
import requests
|
import requests
|
||||||
@ -132,16 +132,26 @@ class BlockStackApp(QWidget):
|
|||||||
|
|
||||||
# Add a close button
|
# Add a close button
|
||||||
btn_close = QPushButton("Close")
|
btn_close = QPushButton("Close")
|
||||||
btn_close.clicked.connect(self.close)
|
btn_close.clicked.connect(self.confirm_close)
|
||||||
bottom_block_layout.addWidget(btn_close)
|
bottom_block_layout.addWidget(btn_close)
|
||||||
|
btn_close.setStyleSheet(f"background-color: #FF0000;")
|
||||||
|
|
||||||
bottom_block_widget.setLayout(bottom_block_layout)
|
bottom_block_widget.setLayout(bottom_block_layout)
|
||||||
self.layout.addWidget(bottom_block_widget)
|
self.layout.addWidget(bottom_block_widget)
|
||||||
|
|
||||||
|
def confirm_close(self):
|
||||||
|
# Create a confirmation dialog
|
||||||
|
confirmation = QMessageBox.question(
|
||||||
|
self,
|
||||||
|
"Confirm Exit",
|
||||||
|
"Are you sure you want to exit?",
|
||||||
|
QMessageBox.Yes | QMessageBox.No,
|
||||||
|
QMessageBox.No
|
||||||
|
)
|
||||||
|
|
||||||
|
# Close the application if the user confirms
|
||||||
|
if confirmation == QMessageBox.Yes:
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user