From: Phil E. <ph...@li...> - 2006-04-12 13:17:43
|
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: def on_mainScriptEditBtn_mouseClick(self, event): editor = self.cfg.get('ConfigData', 'codeeditor') item = self.pathJoin(self.components.mainScript.text) item = os.path.join(self.components.baseDir.text, item) item = os.path.join(self.cfg.get('ConfigData', 'projects'), item) if sys.platform.startswith('win'): editor = GetShortPathName(editor) item = GetShortPathName(item) print editor + ' ' + item os.system(editor + ' ' + item) 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? -- Regards Phil Edwards Brighton, UK |
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 |
From: Ruben M. <rmc...@ya...> - 2006-04-18 13:56:07
|
Phil, You probably found the answer to this issue by now, but just in case you haven't here is a tip. Check your quotes. See here for an interesting sample. http://jason.diamond.name/weblog/2005/04/14/dont-quote-me-on-this -Ruben --- Phil Edwards <ph...@li...> 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: > > def on_mainScriptEditBtn_mouseClick(self, > event): > editor = self.cfg.get('ConfigData', > 'codeeditor') > item = > self.pathJoin(self.components.mainScript.text) > item = > os.path.join(self.components.baseDir.text, item) > item = > os.path.join(self.cfg.get('ConfigData', 'projects'), > item) > if sys.platform.startswith('win'): > editor = GetShortPathName(editor) > item = GetShortPathName(item) > print editor + ' ' + item > os.system(editor + ' ' + item) > > 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? > > > > -- > > Regards > > Phil Edwards > Brighton, UK > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a > groundbreaking scripting language > that extends applications into web and mobile media. > Attend the live webcast > and join the prime developer group breaking into > this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |