# HG changeset patch # User Dirk Olmes # Date 1411175546 -7200 # Node ID 77fa82dcc95686aa7b2ece6b9dea5df6ed426b8c # Parent 71c9c315cfada424ff1106e62b8eefaced2e5182 add a settings object that is read when the main window is opened and persisted when the main window closes diff -r 71c9c315cfad -r 77fa82dcc956 RemoteViewer/RemoteViewer.py --- a/RemoteViewer/RemoteViewer.py Sat Sep 20 02:50:37 2014 +0200 +++ b/RemoteViewer/RemoteViewer.py Sat Sep 20 03:12:26 2014 +0200 @@ -2,11 +2,13 @@ from PyQtLib.ExceptionSafeSlot import ExceptionSafeSlot from .ConnectionDialog import ConnectionDialog +from .Settings import Settings from .Ui_RemoteViewer import Ui_RemoteViewer class RemoteViewer(QMainWindow): def __init__(self): super(RemoteViewer, self).__init__() + self.settings = Settings() self.ui = Ui_RemoteViewer() self.ui.setupUi(self) @@ -15,3 +17,7 @@ dialog = ConnectionDialog() dialog.setWindowTitle('New Connection') dialog.exec_() + + def close(self): + self.settings.persist() + super(RemoteViewer, self).close() diff -r 71c9c315cfad -r 77fa82dcc956 RemoteViewer/Settings.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RemoteViewer/Settings.py Sat Sep 20 03:12:26 2014 +0200 @@ -0,0 +1,15 @@ + +from os.path import expanduser +from configparser import ConfigParser + +class Settings(object): + def __init__(self): + self.parser = ConfigParser() + self.parser.read(self.__filename()) + + def __filename(self): + return expanduser('~/.remoteviewer') + + def persist(self): + with open(self.__filename(), 'w') as rcfile: + self.parser.write(rcfile)