python - 如何运行一个好的easygui选择框功能
问题描述
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")
当我选择某些东西时,消息框就不会出来
解决方案
choicebox
您正在针对您的字符串测试该函数。相反,针对您的字符串测试函数的结果。choicebox
为了使其更清晰,请将其分配给一个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")
推荐阅读
- jmeter - 在 RHEL 8 机器上使用 JMeter 中的 OS 采样器执行文件
- android - 如何在 xamarin 中连接 sqlite
- openssl - 如何针对静态 OpenSSL 库编译应用程序?
- javascript - 在哪里添加用于更新字段的 mongodb 代码
- javascript - 滚动到窗口顶部时元素切换可见性
- .net - 使用 AirPrint 驱动程序 C# .Net 5 MacOS 打印到打印机
- php - 将 /n 添加到 Wordpress (ACF) 中的文本
- c++ - C++ 错误:“QueryFullProcessImageNameA”未在此范围内声明
- nginx - NGINX 上不同子目录上的多个 Yii2 高级模板项目
- curl - 卷曲 - 读取 json 编码错误的响应