By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,973 Members | 1,854 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,973 IT Pros & Developers. It's quick & easy.

Py2Exe and sys.argv : The Lost Arguments

P: n/a
I've created a simple script like so :

import sys
import wx

app = wx.PySimpleApp()
dlg = wx.MessageDialog(None, "%s" % sys.argv, 'A Message Box',
wx.YES_NO | wx.ICON_QUESTION)
retCode = dlg.ShowModal()
app.MainLoop()

If I run this on the command line like
python testcmd.py <path-to>/somefile.ext <path-to>/anotherfile.ext

it displays a messagebox with a stringformatted list containing
testcmd.py, somefile.ext and anotherfile.ext.

Then I "compile" the script using py2exe, generate a file called
testcmd.exe and select the same two files in Explorer, right click,
"Open with ...", browse to testcmd.exe and proceed. Now the dialogbox
only shows two items in the list; testcmd.exe and one of the files I
selected. Why?

Is it impossible to compile a script using py2exe and pass selected
items in Explorer to my script? It works fine when called on the
command line so it might be something related to Explorer but I'm
completly lost.

Aug 17 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I entered the following simple program, compiled with py2exe (2.4)
and ran it the way you describe with two files selected and it
did what you said (e.g. only shows ays.argv[0] and sys.argv[1]):

import sys
print sys.argv
x=raw_input('Press return to continue')

Under 2.5 it didn't work at all (not sure why).

Funny thing is that if I select two .txt files and do a Open With
Notepad, Explorer only opens one of them. So I think it is
Explorer that is throwing away the extra arguments. Otherwise
I would expect it to open multiple notepad instances.

-Larry Bates
Thomas W wrote:
I've created a simple script like so :

import sys
import wx

app = wx.PySimpleApp()
dlg = wx.MessageDialog(None, "%s" % sys.argv, 'A Message Box',
wx.YES_NO | wx.ICON_QUESTION)
retCode = dlg.ShowModal()
app.MainLoop()

If I run this on the command line like
python testcmd.py <path-to>/somefile.ext <path-to>/anotherfile.ext

it displays a messagebox with a stringformatted list containing
testcmd.py, somefile.ext and anotherfile.ext.

Then I "compile" the script using py2exe, generate a file called
testcmd.exe and select the same two files in Explorer, right click,
"Open with ...", browse to testcmd.exe and proceed. Now the dialogbox
only shows two items in the list; testcmd.exe and one of the files I
selected. Why?

Is it impossible to compile a script using py2exe and pass selected
items in Explorer to my script? It works fine when called on the
command line so it might be something related to Explorer but I'm
completly lost.
Aug 17 '06 #2

P: n/a
At Thursday 17/8/2006 16:42, Thomas W wrote:
>Is it impossible to compile a script using py2exe and pass selected
items in Explorer to my script? It works fine when called on the
command line so it might be something related to Explorer but I'm
completly lost.
Yes, it is related to Explorer -some misbehaving context menu
extension-. See
<http://groups.google.com/group/microsoft.public.windowsxp.basics/browse_frm/thread/5d7a111f31fa7901>

But, maybe next time, you could try and exclude all other variables
(wxWindows, py2exe...) to keep things simple...

Gabriel Genellina
Softlab SRL

__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas

Aug 19 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.