From: Alex T. <al...@tw...> - 2006-04-12 16:04:30
|
Phil Edwards wrote: >Hi All: > >Coming from a Linux background, I'm struggling to understand some of the >things that appear to be going on behind the scenes when I'm coding stuff to >run under Windows XP. > >The application in question has a textfield containing the name of a Python >source code file and an 'Edit...' button next to it. When I click the button, >I'm running this code: > > >When the code runs, it prints out what I'm expecting, namely that I'm trying >to run the Pythoncard code editor with the name of a script file as the only >parameter on the command line. I then get the standard 'windows cannot open >this file' dialog box and I get to tell Windows that I want codeEditor.py to >be opened using the program called 'python'. The codeEditor duly opens up, >but it seems as though Windows is somehow losing my command line parameter >and all I end up with is a blank codeEditor window, instead of it opening the >file I wanted it to. Adding a simple 'print sys.argv' to the top of the >codeEditor proves that this is the case. > >Could somebody please explain to a dumb UNIX user what vital piece of >information I'm missing in order to make this work? > > > Explain it ? No, I don't think I can do that. Give you something that works ? - Maybe. Here's what I tried - paths hard-coded for my system. The first time it starts up, no argument is successfully passed. Second time it works as hoped for .... > def on_Button1_mouseClick(self, event): > editor = "c:\\python\\PythonCard\\tools\\oneEditor\\test.py" > item = "c:\\python\\PythonCard\\tools\\oneEditor\\test.py" > print editor + ' ' + item > os.system(editor + ' ' + item) > os.system("python " + editor + ' ' + item) I'm not sure if it is always safe to just prepend the python command - may depend on the Python installation. You should be able to avoid any danger there by using the code used from the codeEditor to run a script (see function runScript) -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.385 / Virus Database: 268.4.1/309 - Release Date: 11/04/2006 |