Created
March 21, 2024 00:04
-
-
Save psifertex/b52e8c5df590f9ec271319ac2bef78ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PySide6.QtWidgets import QApplication, QMainWindow, QMessageBox, QPushButton | |
from PySide6.QtCore import Qt | |
import sys | |
class MainWindow(QMainWindow): | |
def __init__(self): | |
super().__init__() | |
self.setWindowTitle("QT Test") | |
button = QPushButton("Test Dialog") | |
button.clicked.connect(self.button_click) | |
self.setCentralWidget(button) | |
def button_click(self): | |
msgBox = QMessageBox(self) | |
msgBox.setIcon(QMessageBox.Question) | |
msgBox.setText("Quit?") | |
msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel) | |
result = msgBox.exec() | |
match result: | |
case QMessageBox.Save: | |
print("Save") | |
case QMessageBox.Discard: | |
print("Discard") | |
case QMessageBox.Cancel: | |
print("Cancel") | |
return True | |
app = QApplication(sys.argv) | |
window = MainWindow() | |
window.show() | |
app.exec() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment