Merge pull request #497 from SpeedProg/master

Added commandline arguments to specify window title and path for savefiles
This commit is contained in:
blitzmann
2016-03-10 23:58:56 -05:00
3 changed files with 18 additions and 6 deletions

View File

@@ -60,7 +60,7 @@ def __createDirs(path):
if not os.path.exists(path):
os.makedirs(path)
def defPaths():
def defPaths(customSavePath):
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 customSavePath is None: # customSavePath is not overriden
savePath = unicode(os.path.expanduser(os.path.join("~", ".pyfa")),
sys.getfilesystemencoding())
else:
savePath = customSavePath
__createDirs(savePath)

View File

@@ -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

13
pyfa.py
View File

@@ -43,6 +43,8 @@ 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)
parser.add_option("-s", "--savepath", action="store", dest="savepath", help="Set the folder for savedata", default=None)
(options, args) = parser.parse_args()
@@ -99,9 +101,16 @@ 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()
# 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
@@ -123,5 +132,5 @@ if __name__ == "__main__":
eos.db.saveddata_meta.create_all()
pyfa = wx.App(False)
MainFrame()
MainFrame(options.title)
pyfa.MainLoop()