-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriver.py
More file actions
54 lines (47 loc) · 1.88 KB
/
driver.py
File metadata and controls
54 lines (47 loc) · 1.88 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# -*- coding: utf-8 -*-
"""
Created on Thu May 26 15:31:21 2022
@author: hcaslan
"""
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication, QMessageBox, QMainWindow, QAction
from qt import Ui_MainWindow
import sys
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
# Set up the user interface from Designer.
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
#closing alert
def closeEvent(self, event):
close = QMessageBox()
close.setWindowTitle("Window Close")
close.setIcon(QMessageBox.Critical)
close.setText("Are you sure you want to close the window?")
close.setStandardButtons(QMessageBox.Yes | QMessageBox.Cancel)
close.setDefaultButton(QMessageBox.Cancel)
#If there is no output or if the output has already been saved in a way, do not ask if it is desired to save when closing.
if(self.ui.pB_clearOutput.isEnabled() == False or self.ui.pB_exportAsOutput.isEnabled() == False or self.ui.pB_saveAsOutput.isEnabled() == False or self.ui.pB_saveOutput.isEnabled() == False):
close = close.exec()
if close == QMessageBox.Yes:
event.accept()
else:
event.ignore()
#else ask the user for if it is desired to save when closing.
else:
close.setStandardButtons(QMessageBox.Yes | QMessageBox.Save | QMessageBox.Cancel)
close = close.exec()
if close == QMessageBox.Yes:
print("Yes")
event.accept()
elif close == QMessageBox.Save:
print("Save")
self.op.saveAsOutputImage(self.ui)
else:
print("Ignore")
event.ignore()
app = QApplication(sys.argv)
MainWindow = MainWindow()
MainWindow.show()
sys.exit(app.exec_())