首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用multenterboxes EasyGui

使用multenterboxes EasyGui
EN

Stack Overflow用户
提问于 2016-06-01 21:17:59
回答 2查看 304关注 0票数 0

我正在使用easygui | Python。

代码语言:javascript
复制
import easygui as eg
fields = ["juvenile","adult","senile"];
message = "Please fill in the boxes";
windowtitle = "set generation values";
while True:
    inputvalues = eg.multenterbox(message, windowtitle, fields);
    valid = True;
    if inputvalues == None:
        eg.msgbox("You did not fill out the boxes!", "error");
        continue;
    for value in inputvalues:
        if value == "":
            valid = False;
            break;
    if valid == True:
        break;
    else:
        eg.msgbox("You did not fill in one of the boxes!", "error");

这是我做的多人盒子。我需要关于如何使用多项框中的值的帮助。例如:

代码语言:javascript
复制
if juvenile == 100:
    eg.msgbox("there are 100 juveniles in your population")

我的这部分代码没有响应,有人知道解决方案吗?

EN

回答 2

Stack Overflow用户

发布于 2016-12-11 06:24:57

我认为您的问题是,您正在尝试检查juvenile是否为int,但multenterbox返回了一个字符串列表。

所以这可能会解决这个问题:

代码语言:javascript
复制
if juvenile=="100":
    eg.msgbox("there are 100 juveniles in your population")
票数 1
EN

Stack Overflow用户

发布于 2019-07-21 03:55:12

因为Easygui返回List,所以使用rescriptable (我不知道它叫什么,但我称之为它!)函数,我指的是[start, end, (action)]

因此,因为juvenile是第一个,所以我们将这样做:

代码语言:javascript
复制
if inputvalues[0] == "100":  # It needs to be `0` in `[]` because it means first. Second is `1` and continue
    # Do something

并继续

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37569889

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档