From 96048b513362cc75ae2a18c7f1e2de498f0e5fe8 Mon Sep 17 00:00:00 2001 From: Constantin Wenger Date: Tue, 12 Jan 2016 18:46:24 +0100 Subject: [PATCH 1/3] added command line option to set the window title --- gui/mainFrame.py | 4 ++-- pyfa.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gui/mainFrame.py b/gui/mainFrame.py index 3c47e08fd..6d56f7918 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -116,8 +116,8 @@ class MainFrame(wx.Frame): def getInstance(cls): return cls.__instance if cls.__instance is not None else MainFrame() - def __init__(self): - self.title="pyfa %s%s - Python Fitting Assistant"%(config.version, "" if config.tag.lower() != 'git' else " (git)") + def __init__(self, title): + self.title=title wx.Frame.__init__(self, None, wx.ID_ANY, self.title) MainFrame.__instance = self diff --git a/pyfa.py b/pyfa.py index c4a39c9d6..bf51de26a 100755 --- a/pyfa.py +++ b/pyfa.py @@ -43,6 +43,7 @@ parser = PassThroughOptionParser(usage=usage) parser.add_option("-r", "--root", action="store_true", dest="rootsavedata", help="if you want pyfa to store its data in root folder, use this option", default=False) parser.add_option("-w", "--wx28", action="store_true", dest="force28", help="Force usage of wxPython 2.8", default=False) parser.add_option("-d", "--debug", action="store_true", dest="debug", help="Set logger to debug level.", default=False) +parser.add_option("-t", "--title", action="store", dest="title", help="Set Window Title", default=None) (options, args) = parser.parse_args() @@ -99,6 +100,10 @@ if __name__ == "__main__": # Configure paths if options.rootsavedata is True: config.saveInRoot = True + + # set title if it wasn't supplied by argument + if options.title == None: + options.title = "pyfa %s%s - Python Fitting Assistant"%(config.version, "" if config.tag.lower() != 'git' else " (git)") config.debug = options.debug config.defPaths() @@ -123,5 +128,5 @@ if __name__ == "__main__": eos.db.saveddata_meta.create_all() pyfa = wx.App(False) - MainFrame() + MainFrame(options.title) pyfa.MainLoop() From f0775af4396a77b54c081dd3e8f87a75675ad260 Mon Sep 17 00:00:00 2001 From: Constantin Wenger Date: Tue, 12 Jan 2016 18:46:59 +0100 Subject: [PATCH 2/3] added command line option to specify the savepath --- config.py | 7 +++++-- pyfa.py | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index 99dfb1ed4..b7025c664 100644 --- a/config.py +++ b/config.py @@ -60,7 +60,7 @@ def __createDirs(path): if not os.path.exists(path): os.makedirs(path) -def defPaths(): +def defPaths(savepath): global debug global pyfaPath global savePath @@ -87,8 +87,11 @@ def defPaths(): else: savePath = getattr(configforced, "savePath", None) if savePath is None: - savePath = unicode(os.path.expanduser(os.path.join("~", ".pyfa")), + if savepath is None: # savepath is not overriden + savePath = unicode(os.path.expanduser(os.path.join("~", ".pyfa")), sys.getfilesystemencoding()) + else: + savePath = savepath __createDirs(savePath) diff --git a/pyfa.py b/pyfa.py index bf51de26a..146ea704d 100755 --- a/pyfa.py +++ b/pyfa.py @@ -44,6 +44,7 @@ parser.add_option("-r", "--root", action="store_true", dest="rootsavedata", help parser.add_option("-w", "--wx28", action="store_true", dest="force28", help="Force usage of wxPython 2.8", default=False) parser.add_option("-d", "--debug", action="store_true", dest="debug", help="Set logger to debug level.", default=False) parser.add_option("-t", "--title", action="store", dest="title", help="Set Window Title", default=None) +parser.add_option("-s", "--savepath", action="store", dest="savepath", help="Set the folder for savedata", default=None) (options, args) = parser.parse_args() @@ -106,7 +107,10 @@ if __name__ == "__main__": options.title = "pyfa %s%s - Python Fitting Assistant"%(config.version, "" if config.tag.lower() != 'git' else " (git)") config.debug = options.debug - config.defPaths() + # convert to unicode if it is set + if options.savepath is not None: + options.savepath = unicode(options.savepath) + config.defPaths(options.savepath) # Basic logging initialization import logging From 02d4ac81dd177821ddfc3dfd5306540e1bea848f Mon Sep 17 00:00:00 2001 From: Constantin Wenger Date: Fri, 5 Feb 2016 13:10:18 +0100 Subject: [PATCH 3/3] renamed parameter savepath to customSavePath for better distinguishability to savePath --- config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index b7025c664..b2d8fc95f 100644 --- a/config.py +++ b/config.py @@ -60,7 +60,7 @@ def __createDirs(path): if not os.path.exists(path): os.makedirs(path) -def defPaths(savepath): +def defPaths(customSavePath): global debug global pyfaPath global savePath @@ -87,11 +87,11 @@ def defPaths(savepath): else: savePath = getattr(configforced, "savePath", None) if savePath is None: - if savepath is None: # savepath is not overriden + if customSavePath is None: # customSavePath is not overriden savePath = unicode(os.path.expanduser(os.path.join("~", ".pyfa")), sys.getfilesystemencoding()) else: - savePath = savepath + savePath = customSavePath __createDirs(savePath)