0

Been using easygui in python to make gui boxes for various different system applications for windows over the past few days. What I want to know is, why doesn't my code work? It looks the same as the code that was working before? The program is a game launcher, and I shall be making one identical to this but working (with different, LAN compatible games) for people to select the game from the list. Looked on stack overflow and found somebody with a similar issue, however I don't believe his resolution would apply to my script. Will post code below,

thank you,

Matthew

import easygui as eg
import os
def menu():
    msg="Please select a game:"
    title="Select Game!"
    choices=["Batman Arkham City", "Tomb Raider", "TESV Skyrim", "State of decay -     Early Access", "Critical Strike Portable", "Terraria", "Doom", "Halo","Minecraft"]
reply=eg.buttonbox(msg,title,choices)
    if choices=="Batman Arkham City":
        batman()
elif choices=="Tomb Raider":
    tomb()
elif choices=="TESV Skyrim":
    skyrim()
elif choices=="State of decay - Early Access":
    state()
elif choices=="Critical Strike Portable":
    crs()
elif choices=="Terraria":
    terr()
elif choices=="Doom":
    doom()
elif choices=="Halo":
    halo()
elif choices=="Minecraft":
    minecraft()
def batman():
os.system('"C:\Program Files (x86)\Black_Box\Batman Arkham   City\Binaries\Win32\BatmanAC.exe"')
menu()
def tomb():
os.system('"C:\Program Files (x86)\Tomb Raider\TombRaider.exe"')
menu()
def skyrim():
os.system('"C:\Program Files (x86)\The Elder Scrolls V Skyrim\SkyrimLauncher.exe"')
menu()
def state():
os.system('"C:\Games\State of Decay Early Access\StateOfDecay.exe"')
menu()
def crs():
os.system('"C:\Program Files (x86)\CS Portable\a.exe"')
menu()
def terr():
os.system('"C:\Games\Terraria\Terraria.exe"')
menu()
def doom():
os.system('"C:\DOOMWADS\doom.wad"')
menu()
def halo():
os.system('"C:\Program Files (x86)\Halo Combat Evolved\Halo.exe"')
menu()
def minecraft():
os.system('"C:\Games\minecraft.exe"')
menu()
menu()

Stack overflow has messed up my indents! Please assume these are correct as they are.

4

2 回答 2

1

这是导致问题的反斜杠。Python 自己解释这些,例如 \n 是一个换行符。

将它们更改为正斜杠或双反斜杠。

os.system('"C:/DOOMWADS/doom.wad"')
于 2013-10-10T10:16:07.807 回答
0

我已经修好了....抱歉浪费了任何人的时间。反斜杠很好,因为它们在 '""' 中,但是在菜单部分中是 "if choice=="game"" 而它应该是 "if reply=="game""。谢谢您的帮助!:)

于 2013-10-10T12:03:49.903 回答