1
|
|
|
# Third party imports |
2
|
|
|
from qtpy.QtCore import Qt |
3
|
|
|
from qtpy.QtGui import QPixmap |
4
|
|
|
from qtpy.QtWidgets import (QApplication, QDialogButtonBox, QDialog, |
5
|
|
|
QHBoxLayout, QLabel, QPushButton, QVBoxLayout) |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
class ClosePackageManagerDialog(QDialog): |
9
|
|
|
""" |
10
|
|
|
""" |
11
|
|
|
def __init__(self, *args, **kwargs): |
12
|
|
|
super(ClosePackageManagerDialog, self).__init__(*args, **kwargs) |
13
|
|
|
self.label_icon = QLabel() |
14
|
|
|
self.label_about = QLabel('Conda is still busy.\n\n' |
15
|
|
|
'Do you want to cancel the process?') |
16
|
|
|
self.button_ok = QPushButton('Yes') |
17
|
|
|
self.button_cancel = QPushButton('No') |
18
|
|
|
self.buttonbox = QDialogButtonBox(Qt.Horizontal) |
19
|
|
|
|
20
|
|
|
# Widget setup |
21
|
|
|
self.buttonbox.addButton(self.button_ok, QDialogButtonBox.ActionRole) |
22
|
|
|
self.buttonbox.addButton(self.button_cancel, |
23
|
|
|
QDialogButtonBox.ActionRole) |
24
|
|
|
# self.label_icon.setPixmap(QPixmap(images.ANACONDA_ICON_64_PATH)) |
25
|
|
|
self.setWindowTitle("Cancel Process") |
26
|
|
|
|
27
|
|
|
# Layouts |
28
|
|
|
h_layout = QHBoxLayout() |
29
|
|
|
h_layout.addWidget(self.label_icon, 0, Qt.AlignTop) |
30
|
|
|
h_layout.addSpacing(10) |
31
|
|
|
h_layout.addWidget(self.label_about) |
32
|
|
|
|
33
|
|
|
main_layout = QVBoxLayout() |
34
|
|
|
main_layout.addLayout(h_layout) |
35
|
|
|
main_layout.addSpacing(20) |
36
|
|
|
main_layout.addWidget(self.buttonbox) |
37
|
|
|
self.setLayout(main_layout) |
38
|
|
|
|
39
|
|
|
# Signals |
40
|
|
|
self.button_ok.clicked.connect(self.accept) |
41
|
|
|
self.button_cancel.clicked.connect(self.reject) |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
def test(): |
45
|
|
|
app = QApplication([]) |
46
|
|
|
dlg = ClosePackageManagerDialog(parent=None) |
47
|
|
|
reply = dlg.exec_() |
48
|
|
|
print(reply) |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
if __name__ == '__main__': |
52
|
|
|
test() |
53
|
|
|
|