forked from dragondjf/QMarkdowner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexitdialog.py
79 lines (65 loc) · 2.83 KB
/
exitdialog.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
from qframer.qt import QtGui
from qframer.qt import QtCore
from basedialog import BaseDialog
class ExitDialog(BaseDialog):
def __init__(self, styleoptions, parent=None):
super(ExitDialog, self).__init__(styleoptions, parent)
# 退出设置
self.exitoptwidget = QtGui.QWidget()
exit_mainlayout = QtGui.QGridLayout()
self.exitradiogroup = QtGui.QButtonGroup(self.exitoptwidget)
self.minRadio = QtGui.QRadioButton(u'最小化')
self.exitRadio = QtGui.QRadioButton(u'退出')
self.exitsaveRadio = QtGui.QRadioButton(u'退出并保存配置')
self.exitradiogroup.addButton(self.minRadio)
self.exitradiogroup.addButton(self.exitRadio)
self.exitradiogroup.addButton(self.exitsaveRadio)
exit_mainlayout.addWidget(self.minRadio, 0, 0)
exit_mainlayout.addWidget(self.exitRadio, 1, 0)
exit_mainlayout.addWidget(self.exitsaveRadio, 2, 0)
self.exitoptwidget.setLayout(exit_mainlayout)
self.exitsaveRadio.setChecked(True)
#确认按钮布局
self.enterwidget = QtGui.QWidget()
self.pbEnter = QtGui.QPushButton(u'确定', self)
self.pbCancel = QtGui.QPushButton(u'取消', self)
self.pbEnter.clicked.connect(self.exit)
self.pbCancel.clicked.connect(self.close)
enterwidget_mainlayout = QtGui.QGridLayout()
enterwidget_mainlayout.addWidget(self.pbEnter, 0, 0)
enterwidget_mainlayout.addWidget(self.pbCancel, 0, 1)
self.enterwidget.setLayout(enterwidget_mainlayout)
self.layout().addWidget(self.exitoptwidget)
self.layout().addWidget(self.enterwidget)
self.resize(self.width(), self.height())
self.exitflag = {}
def exit(self):
for radio in ['minRadio', 'exitRadio', 'exitsaveRadio']:
if getattr(self, radio) is self.exitradiogroup.checkedButton():
self.exitflag.update({radio: True})
else:
self.exitflag.update({radio: False})
self.accept()
def exit(options):
"""返回True或False"""
dialog = ExitDialog(options)
if dialog.exec_():
return True, dialog.exitflag
else:
return False, dialog.exitflag
if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
styleoptions = {
'title': u'退出设置',
'windowicon': os.sep.join([os.path.dirname(__file__), 'utildialogskin', 'images', 'bg.jpg']),
'minsize': (400, 300),
'size': (400, 300),
'logo_title': u'智能光纤云终端管理平台',
'logo_img_url': os.sep.join([os.path.dirname(__file__), 'utildialogskin', 'images', 'bg.jpg'])
}
print exit(styleoptions)
sys.exit(app.exec_())