我如何运行一个好的easygui choicebox功能

How do I run a good easygui choicebox function

        if event.type == MOUSEBUTTONUP:
            mouseX, mouseY=event.pos
            if warsaw_button.collidepoint(mouseX,mouseY):
                choices = ["build a structure", "acquire units", "destroy structure", "launch from silo"]
                choicebox("What do you want to do commander?", warsaw_name, choices)
                if choicebox == choices[0]:
                    msgbox("you want to build a structure")
                elif choicebox == choices[1]:
                    msgbox("you want to acquire more units")
                elif choicebox == choices[2]:
                    msgbox("you want to destroy structures you built")
                elif choicebox == choices[3]:
                    msgbox("you want to launch missile from a silo")

每当我选择一些东西时,msgbox 就是不出来

您正在针对您的字符串测试 choicebox 函数。相反,请针对您的字符串测试 choicebox 函数的 result。为了使它更清晰,将它分配给一个 choice 变量。

        if event.type == MOUSEBUTTONUP:
            mouseX, mouseY=event.pos
            if warsaw_button.collidepoint(mouseX,mouseY):
                choices = ["build a structure", "acquire units", "destroy structure", "launch from silo"]
                choice = choicebox("What do you want to do commander?", warsaw_name, choices)
                if choice == choices[0]:
                    msgbox("you want to build a structure")
                elif choice == choices[1]:
                    msgbox("you want to acquire more units")
                elif choice == choices[2]:
                    msgbox("you want to destroy structures you built")
                elif choice == choices[3]:
                    msgbox("you want to launch missile from a silo")