at541
at541

Reputation: 247

Python EasyGui : Returning User Input In TextBoxes

Hello i am currently using python 2.7 to create a GUI based program with the add on library EasyGui. I'm trying to take the user input from a multiline textbox and print those values to another function which displays inside a messagebox. currently my code looks like this:


fieldNames = ["Name","Street Address","City","State","ZipCode"]
fieldValues = []

def multenterbox123():
        multenterbox(msg='Fill in values for the fields.', title='Enter', fields=(fieldNames), values=(fieldValues))
        return fieldValues

   multenterbox123(); 

msgbox(msg=(fieldValues), title = "Results")

its currently returing a blank value in the messagebox (msgbox) and i understand why its doing this , as its pointing to the blank list variable fieldValues. I actually want to take the list values after its passed in from the user in the multi line textbox (multenterbox123) function, but im having trouble trying to work out how to best implement this.

Any help into this would be greatly appreciated as im only new to python programming (:

Upvotes: 1

Views: 2237

Answers (1)

Dor-Ron
Dor-Ron

Reputation: 1807

from easygui import msgbox, multenterbox

fieldNames = ["Name", "Street Address", "City", "State", "ZipCode"]
fieldValues = list(multenterbox(msg='Fill in values for the fields.', title='Enter', fields=(fieldNames)))
msgbox(msg=(fieldValues), title = "Results")

I tested the code above on my computer and the msgbox returned what I entered in the multenterbox . There is an example in the documentation if you want to take a look at it. Multenterbox-EasyGUI-Documentation. Basically you first need to make a list, hence the list function. And all the values entered will be stored in it. So whatever I write in the multenterbox will be saved in the fieldValues list.

Upvotes: 3

Related Questions