pyqt-todolist/view/SettingWidget.py

41 lines
1.3 KiB
Python
Raw Normal View History

from PyQt5.QtCore import Qt, pyqtSignal, QRect
2022-04-26 21:10:49 +08:00
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from utils.BasicUtils import read_ini, set_exit_status
class SettingWidget(QWidget):
update_signal = pyqtSignal()
def __init__(self):
super(SettingWidget, self).__init__()
self.setWindowTitle('设置')
# self.resize(400, 300)
2022-04-26 21:10:49 +08:00
layout = QFormLayout()
self.setLayout(layout)
self.combo = QComboBox()
exit_status = read_ini('System', 'exitstatus')
# 设置气泡在屏幕上的位置水平居中垂直屏幕80%位置
desktop = QApplication.desktop()
self.setGeometry(QRect(int(desktop.width() / 2 - 75), int(desktop.height() * 0.5), 400, 300))
2022-04-26 21:10:49 +08:00
self.combo.addItem('最小化到托盘')
self.combo.addItem('退出程序')
index = 0
if exit_status == 'Exit':
index = 1
self.combo.setCurrentIndex(index)
self.combo.currentIndexChanged.connect(lambda: self.save_exit_status(self.combo.currentIndex()))
layout.addRow('关闭窗口时', self.combo)
# layout.addWidget(self.setting_widget)
def save_exit_status(self, index):
print(index)
status = ['Min', 'Exit']
2022-04-26 21:10:49 +08:00
set_exit_status(status[index])
self.update_signal.emit()