hikyuu2/hikyuu/admin/UiConfig.py

26 lines
926 B
C++
Raw Normal View History

2021-04-17 19:29:30 +08:00
# -*- coding: utf-8 -*-
import os
from configparser import ConfigParser
class UiConfig(ConfigParser):
2021-04-18 01:59:48 +08:00
def __init__(self):
2021-04-17 19:29:30 +08:00
super(UiConfig, self).__init__()
self.config_path = "%s/.hikyuu/admin" % os.path.expanduser('~')
self.config_file = '%s/ui.ini' % self.config_path
if os.path.exists(self.config_file):
self.read(self.config_file, encoding='utf-8')
if not self.has_section('main_window'):
self.add_section('main_window')
2021-04-19 01:41:03 +08:00
def save(self, main_window):
2021-04-18 01:59:48 +08:00
self.set('main_window', 'width', str(main_window.width()))
self.set('main_window', 'height', str(main_window.height()))
self.set('main_window', 'maximized', str(main_window.isMaximized()))
2021-04-17 19:29:30 +08:00
if not os.path.lexists(self.config_path):
os.makedirs(self.config_path)
with open(self.config_file, 'w', encoding='utf-8') as f:
self.write(f)