summaryrefslogtreecommitdiff
path: root/geneticone/gui/gui_helper.py
diff options
context:
space:
mode:
authornecoro <>2006-10-05 11:56:16 +0000
committernecoro <>2006-10-05 11:56:16 +0000
commitdfbeab611f68502631ed4c575f5809064c948d58 (patch)
tree626675b36f327588ce3ef9d70f28fd5547e94570 /geneticone/gui/gui_helper.py
parent46c5530abed392a2d7d91da165cffca99938f906 (diff)
downloadportato-dfbeab611f68502631ed4c575f5809064c948d58.tar.gz
portato-dfbeab611f68502631ed4c575f5809064c948d58.tar.bz2
portato-dfbeab611f68502631ed4c575f5809064c948d58.zip
Added preference window
Diffstat (limited to '')
-rw-r--r--geneticone/gui/gui_helper.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/geneticone/gui/gui_helper.py b/geneticone/gui/gui_helper.py
index acbccd3..32dd56f 100644
--- a/geneticone/gui/gui_helper.py
+++ b/geneticone/gui/gui_helper.py
@@ -16,10 +16,48 @@ import windows
from subprocess import *
from threading import Thread
+from ConfigParser import SafeConfigParser
import pty
import vte
+class Config:
+ const = {
+ "main_sec" : "Main",
+ "usePerVersion_opt" : "usePerVersion",
+ "useFile_opt" : "usefile"
+ }
+
+ def __init__ (self, cfgFile):
+ self._cfg = SafeConfigParser()
+ if not isinstance(cfgFile, file):
+ self._file = open(cfgFile) # assume string
+ elif cfgFile.closed:
+ self._file = open(cfgFile.name)
+ else:
+ self._file = cfgFile
+
+ self._cfg.readfp(self._file)
+ self._file.close()
+
+ def get(self, name, section=const["main_sec"]):
+ return self._cfg.get(section, name)
+
+ def get_boolean(self, name, section=const["main_sec"]):
+ return self._cfg.getboolean(section, name)
+
+ def modify_flags_config (self):
+ flagCfg = {"usefile": self.get(self.const["useFile_opt"]), "usePerVersion" : self.get_boolean(self.const["usePerVersion_opt"])}
+ flags.set_config(flagCfg)
+
+ def set(self, name, val, section=const["main_sec"]):
+ self._cfg.set(section, name, val)
+
+ def write(self):
+ self._file = open(self._file.name,"w")
+ self._cfg.write(self._file)
+ self.modify_flags_config()
+
class Database:
"""An internal database which holds a simple dictionary cat -> [package_list]."""