A.U
A.U

Reputation: 11

Working with multenterboxes - EasyGui

I am using easygui | Python.

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");

Here is my multenter box I have made. I need help on how to work with the values in the multenter box. for example:

if juvenile == 100:
    eg.msgbox("there are 100 juveniles in your population")

This part of my code does not respond, anyone know the solution?

Upvotes: 0

Views: 473

Answers (2)

USLTD
USLTD

Reputation: 309

Because Easygui returns List, use rescriptable (I don't know what it's called but I call this!) function where I mean [start, end, (action)].

So because juvenile is first we will do as:

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

and continue

Upvotes: 0

arsus
arsus

Reputation: 11

I think your problem is that you're trying to check if juvenile is an int, but the multenterbox returns a list of strings.

So maybe this will fix it:

if juvenile=="100":
    eg.msgbox("there are 100 juveniles in your population")

Upvotes: 1

Related Questions