pyqt-todolist/view/SettingWidget.py

36 lines
1 KiB
Python
Raw Normal View History

2022-04-26 21:10:49 +08:00
from PyQt5.QtCore import Qt, pyqtSignal
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)
layout = QFormLayout()
self.setLayout(layout)
self.combo = QComboBox()
exit_status = read_ini('System', 'exitstatus')
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 = ['Mix', 'Exit']
set_exit_status(status[index])