[Tutor] mamelauncher
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Fri Sep 9 23:23:33 CEST 2005
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!
More information about the Tutor
mailing list