[Tutor] mamelauncher

Max Russell max_russell2000 at yahoo.co.uk
Mon Sep 12 21:59:55 CEST 2005


I've tried running that function, with a little Main
method like this:

import os

def run_mame_selection(selection):
    os.system("C:\\mame096b\\mame.exe"+""+selection)

#main
mine = "pacman"
run_mame_selection(mine)    

What I get is like a brief flash of the CMD prompt
like it is trying it and not waiting or getting some
kind of return.

I'm really not sure where I'm going wrong at all! I'll
try re-writing using sub-process as I've upped my
Python to 2.4.


--- Danny Yoo <dyoo at hkn.eecs.berkeley.edu> wrote:

> 
> 
> On Fri, 9 Sep 2005, Max Russell wrote:
> 
> > I've been working on this for ages and am having
> real problems with
> > getting the wiring for a selected game to launch
> when I click OK.
> >
> > I haven't added my error handling yet.
> 
> [code cut]
> 
> 
> Hi Max,
> 
> Hmmm... Out of curiosity, what happens if you try
> doing it without the
> GUI?
> 
> Let's try to isolate the problem; it's not clear at
> the moment if there's
> something weird with the GUI, or if there's
> something weird with the
> os.system() call.
> 
> If you can write a quick test case that calls
> os.system() in the same way,
> then we can be more sure what's causing the problem.
> 
> 
> I see that you have a function called launchmame:
> 
>     def launchmame(self, event):
>         selection = self.lstbx.curselection()
>        
> os.system("C:\\mame096b\\mame.exe"+""+selection)
> 
> (Ah.  I do see a possible problem here, but I want
> YOU to see it too.
> *grin*)
> 
> 
> 
> Try testing out the function:
> 
> ######
> def run_mame_selection(selection):
>     os.system("C:\\mame096b\\mame.exe"+""+selection)
> ######
> 
> It's mostly a copy and paste of what you had in
> launchmame, except that we
> explicitly pass in the selection string.  But try it
> out with a hardcoded
> selection, and see if it succeeds.
> 
> 
> As a side note, you may want to consider using the
> 'subprocess' module
> instead of manually constructing command strings
> through string
> concatenation: doing it by string concatenation is a
> bug-prone process.
> 'subprocess' is less bug-prone, and you can find out
> more here:
> 
>    
> http://www.python.org/doc/lib/module-subprocess.html
> 
> 
> Good luck!
> 
> 



		
___________________________________________________________ 
How much free photo storage do you get? Store your holiday 
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com


More information about the Tutor mailing list