Skip to content

Commit 578d87f

Browse files
author
Ram Rachum
committed
-
1 parent 505a7dc commit 578d87f

File tree

3 files changed

+61
-12
lines changed

3 files changed

+61
-12
lines changed

garlicsim_wx/garlicsim_wx/__init__.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import bootstrap
1717

1818
import sys
19+
import os.path
1920

2021
import wx
2122

@@ -31,15 +32,21 @@
3132
def start():
3233
'''Start the GUI.'''
3334

34-
new_gui_project_simpack_name = None
35-
for arg in sys.argv:
35+
args = sys.argv[:]
36+
# If we're not frozen, the first argument is the path of the script, and
37+
# that should be ignored:
38+
if not hasattr(sys, 'frozen'):
39+
del args[:1]
40+
41+
if args:
42+
arg = args[0]
43+
new_gui_project_simpack_name = None
44+
load_gui_project_file_path = None
45+
3646
if arg.startswith('__garlicsim_wx_new='):
3747
new_gui_project_simpack_name = arg[19:]
38-
39-
load_gui_project_file_path = None
40-
for arg in sys.argv:
41-
if arg.startswith('__garlicsim_wx_load='):
42-
load_gui_project_file_path = arg[20:]
48+
elif os.path.isfile(arg):
49+
load_gui_project_file_path = arg
4350

4451
app = App(new_gui_project_simpack_name=new_gui_project_simpack_name,
4552
load_gui_project_file_path=load_gui_project_file_path)

garlicsim_wx/garlicsim_wx/frame/frame.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import cPickle as pickle_module
1616
import subprocess
1717
import webbrowser
18+
import traceback
1819

1920
import wx
2021
from garlicsim_wx.general_misc.third_party import aui
@@ -344,7 +345,7 @@ def on_open(self, event=None):
344345

345346
open_dialog = wx.FileDialog(self, message='Choose a file',
346347
defaultDir=folder, defaultFile='',
347-
wcd=wildcard, style=wx.OPEN)
348+
wildcard=wildcard, style=wx.OPEN)
348349
if open_dialog.ShowModal() == wx.ID_OK:
349350
path = open_dialog.GetPath()
350351

@@ -357,7 +358,7 @@ def on_open(self, event=None):
357358
program = [sys.executable, os.path.abspath(sys.argv[0])]
358359
# Todo: what if some other program is launching my code?
359360

360-
program.append('__garlicsim_wx_load=%s' % path)
361+
program.append(path)
361362

362363
subprocess.Popen(program)
363364

@@ -372,7 +373,7 @@ def _open_gui_project_from_path(self, path):
372373
except Exception, exception:
373374
dialog = wx.MessageDialog(
374375
self,
375-
'Error opening file:\n' + str(exception),
376+
'Error opening file:\n' + traceback.format_exc(),
376377
style=(wx.OK | wx.ICON_ERROR)
377378
)
378379
dialog.ShowModal()
@@ -384,7 +385,7 @@ def _open_gui_project_from_path(self, path):
384385
except Exception, exception:
385386
dialog = wx.MessageDialog(
386387
self,
387-
'Error opening file:\n' + str(exception),
388+
'Error opening file:\n' + traceback.format_exc(),
388389
style=(wx.OK | wx.ICON_ERROR)
389390
)
390391
dialog.ShowModal()
@@ -402,7 +403,7 @@ def on_save(self, event=None):
402403
try:
403404
save_dialog = wx.FileDialog(self, message='Save file as...',
404405
defaultDir=folder, defaultFile='',
405-
wcd=wildcard,
406+
wildcard=wildcard,
406407
style=wx.SAVE | wx.OVERWRITE_PROMPT)
407408
if save_dialog.ShowModal() == wx.ID_OK:
408409
path = save_dialog.GetPath()

garlicsim_wx/installer_script.iss

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
; Script generated by the Inno Setup Script Wizard.
2+
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
3+
4+
[Setup]
5+
; NOTE: The value of AppId uniquely identifies this application.
6+
; Do not use the same AppId value in installers for other applications.
7+
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
8+
AppId={{0D13DAF6-02E1-4DC4-B919-8B6A9FAE64A6}
9+
AppName=GarlicSim
10+
AppVerName=GarlicSim 0.4
11+
AppPublisher=Ram Rachum
12+
AppPublisherURL=http://garlicsim.org
13+
AppSupportURL=http://garlicsim.org
14+
AppUpdatesURL=http://garlicsim.org
15+
DefaultDirName={pf}\GarlicSim
16+
DefaultGroupName=GarlicSim
17+
AllowNoIcons=yes
18+
OutputDir=.
19+
OutputBaseFilename=setup
20+
Compression=lzma
21+
SolidCompression=yes
22+
23+
[Languages]
24+
Name: "english"; MessagesFile: "compiler:Default.isl"
25+
26+
[Tasks]
27+
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
28+
29+
[Files]
30+
Source: "py2exe_dist/GarlicSim.exe"; DestDir: "{app}"; Flags: ignoreversion
31+
Source: "py2exe_dist/*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
32+
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
33+
34+
[Icons]
35+
Name: "{group}\GarlicSim"; Filename: "{app}\GarlicSim.exe"
36+
Name: "{group}\{cm:UninstallProgram,GarlicSim}"; Filename: "{uninstallexe}"
37+
Name: "{commondesktop}\GarlicSim"; Filename: "{app}\GarlicSim.exe"; Tasks: desktopicon
38+
39+
[Run]
40+
Filename: "{app}\GarlicSim.exe"; Description: "{cm:LaunchProgram,GarlicSim}"; Flags: nowait postinstall skipifsilent
41+

0 commit comments

Comments
 (0)