473,503 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Py2Exe and sys.argv : The Lost Arguments

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
2 3148
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
3661
by: Thomas Heller | last post by:
I'm currently working on a new version of py2exe, which will require Python 2.3 and later, because it uses the zipimport mechanism. Since py2exe is a distutils extension, and since C compilers...
1
3721
by: Peter Teniz | last post by:
hi, i'm trying to generate a service for win XP / win 2k with python2.3.3 + win32all-163 + py2exe0.5.0 (also tried with pywin32-200.win32-py2.3) running the console-script "FBxmlserv.py" with...
3
5690
by: Werner Merkl | last post by:
Hi, Python is really great, for small to big programs. For my colleagues and some circumstances I sometimes need to "compile" a script using py2exe. Cause I use Windows, I like to use the...
1
2578
by: Funduk | last post by:
Hello, So I've been playing with Python and Pygame for a while and I decided I wanted to make a real executable so I could send that stuff over to my friends to show off my <sarcasm>maad...
0
1543
by: Durumdara | last post by:
Hi ! I have an application that I compile to exe. 1.) I want to compile main.ico into exe, or int zip. Can I do it ? 2.) Can I compile the result to my specified directory, not into the...
4
3979
by: bwaha | last post by:
First time trying to create an executable with py2exe. I have a small program which makes use of python23 (2.3.5?), wxpython ('2.6.2.1'), matplotlib ('0.83.2'), win32com (latest?), Numeric...
0
13434
bartonc
by: bartonc | last post by:
You can find the original author of the script by ggling " Py2Exe version 6.3 setup" The cool thing about this is that it calls py2exe, just in case you're uncomfortable with the command line. I had...
1
2284
by: em00100 | last post by:
Dear All, I have try to use the py2exe to compile the DLL file first i write the simple python script "test01.py": def test001(): return 1 then write the setup.py: # setup.py
0
1016
by: Leo Lee | last post by:
Hi, I think I have already solved this problem while I am digging into the installation sources. I found this: C:\Python25\Lib\site-packages\py2exe\samples\singlefile\gui\setup.py # Requires...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.