pyqt-todolist/view/SettingWidget.py

40 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from PyQt5.QtCore import Qt, pyqtSignal, QRect
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')
# 设置气泡在屏幕上的位置水平居中垂直屏幕80%位置
desktop = QApplication.desktop()
self.setGeometry(QRect(int(desktop.width() / 2 - 75), int(desktop.height() * 0.5), 400, 300))
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']
set_exit_status(status[index])
self.update_signal.emit()