summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2011-05-19 22:51:32 +0200
committerKevin Chabowski <kevin@kch42.de>2011-05-19 22:51:32 +0200
commit3787569eeba8fde6b78ea37f2b1d3ad15390c647 (patch)
treea66986d7510feae0218bd16fca0a3b6b61a002d4
parent94637bdf9b4dd4df022fef3993bb00c237b7d1ff (diff)
downloaddotstr_edit-3787569eeba8fde6b78ea37f2b1d3ad15390c647.tar.gz
dotstr_edit-3787569eeba8fde6b78ea37f2b1d3ad15390c647.tar.bz2
dotstr_edit-3787569eeba8fde6b78ea37f2b1d3ad15390c647.zip
An .str file can now be given as a command line argument.
-rwxr-xr-xdotstr_edit.py39
1 files changed, 22 insertions, 17 deletions
diff --git a/dotstr_edit.py b/dotstr_edit.py
index 38b5c7b..24265e8 100755
--- a/dotstr_edit.py
+++ b/dotstr_edit.py
@@ -255,6 +255,25 @@ class editor_frame(wx.Frame):
self.filename = ""
self.form_init()
+ def load_file(self, new_fn):
+ if new_fn != "":
+ try:
+ fp = open(new_fn, "rb")
+ temp_dict = strfile.dict_parse(fp.read())
+ self.dict = temp_dict
+ fp.close()
+ self.filename = new_fn
+ self.changed = False
+ self.form_init()
+ except:
+ del dialog
+ dialog = wx.MessageDialog(None,
+ message=_("Could not open file.\nUsually that means that the file is invalid or you do not have enough privileges."),
+ caption=_("Could not open file"),
+ style=wx.ICON_ERROR | wx.OK)
+ dialog.ShowModal()
+ dialog.Destroy()
+
def on_open(self, event):
if self.really_discard():
new_fn = ""
@@ -263,23 +282,7 @@ class editor_frame(wx.Frame):
new_fn = dialog.GetPath()
dialog.Destroy()
- if new_fn != "":
- try:
- fp = open(new_fn, "rb")
- temp_dict = strfile.dict_parse(fp.read())
- self.dict = temp_dict
- fp.close()
- self.filename = new_fn
- self.changed = False
- self.form_init()
- except:
- del dialog
- dialog = wx.MessageDialog(None,
- message=_("Could not open file.\nUsually that means that the file is invalid or you do not have enough privileges."),
- caption=_("Could not open file"),
- style=wx.ICON_ERROR | wx.OK)
- dialog.ShowModal()
- dialog.Destroy()
+ self.load_file(new_fn)
def save_file(self, force_path=False):
saveto = ""
@@ -419,6 +422,8 @@ class dotstr_edit_app(wx.App):
def OnInit(self):
app_frame = editor_frame()
app_frame.Show()
+ if len(sys.argv) > 1:
+ app_frame.load_file(sys.argv[1])
self.SetTopWindow(app_frame)
return True