Skip to content

Commit

Permalink
Merge pull request #497 from SpeedProg/master
Browse files Browse the repository at this point in the history
Added commandline arguments to specify window title and path for savefiles
  • Loading branch information
blitzmann committed Mar 11, 2016
2 parents fe64e2e + cf60bbc commit e53bd70
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
7 changes: 5 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions gui/mainFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions pyfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def _process_args(self, largs, rargs, values):
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()

Expand Down Expand Up @@ -99,9 +101,16 @@ def _process_args(self, largs, rargs, values):
# 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
Expand All @@ -123,5 +132,5 @@ def _process_args(self, largs, rargs, values):
eos.db.saveddata_meta.create_all()

pyfa = wx.App(False)
MainFrame()
MainFrame(options.title)
pyfa.MainLoop()

0 comments on commit e53bd70

Please sign in to comment.