-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPush_Button.py
More file actions
36 lines (29 loc) · 935 Bytes
/
Push_Button.py
File metadata and controls
36 lines (29 loc) · 935 Bytes
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
import sys
from PyQt5.QtWidgets import QWidget, QApplication, QPushButton, QMessageBox, QToolTip
from PyQt5.QtCore import QCoreApplication
class Window(QWidget):
def __init__(self):
super().__init__();
self.initUI();
def initUI(self):
button = QPushButton('Quit', self);
button.resize(button.sizeHint());
button.move(250, 200);
button.setToolTip('This will force close your window');
button.show();
button.clicked.connect(QCoreApplication.instance().quit);
self.setToolTip('This is a widget');
self.resize(500, 500)
self.move(200, 150);
self.setWindowTitle('Push Button');
self.show();
def closeEvent(self, event):
reply=QMessageBox.question(self, 'Message', 'Are you sure?', QMessageBox.Yes | QMessageBox.No, QMessageBox.No);
if reply == QMessageBox.Yes:
event.accept();
else:
event.ignore();
if __name__=='__main__':
app=QApplication(sys.argv);
w=Window();
sys.exit(app.exec_());