반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
import sys
from PySide6.QtWidgets import QWidget, QApplication, QMessageBox, QPushButton, QVBoxLayout
class MyForm(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
button = QPushButton("Open MessageBox")
button.clicked.connect(self.showMessageBox)
main_layout = QVBoxLayout()
main_layout.addWidget(button)
self.setLayout(main_layout)
def showMessageBox(self):
msgBox = QMessageBox()
msgBox.setWindowTitle("Title of MessageBox")
msgBox.setText("Contents of MessageBox")
msgBox.setInformativeText("InformativeText")
msgBox.setIcon(QMessageBox.Information)
msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Discard | QMessageBox.Cancel)
msgBox.setDefaultButton(QMessageBox.Ok)
result = msgBox.exec()
if result == QMessageBox.Ok:
print("OK")
elif result == QMessageBox.Cancel:
print("Cancel")
elif result == QMessageBox.Discard:
print("Discard")
if __name__ == '__main__':
app = QApplication(sys.argv)
form = MyForm()
form.show()
app.exec_()
|
cs |
반응형
'[Programming] > [PyQt, PySide]' 카테고리의 다른 글
QLineEdit 자동 완성 목록 만들기 (PyQt, PySide) (0) | 2021.05.05 |
---|