简体   繁体   中英

How would I get the information from my dropdown menu to add to my array using python?

I have a number of fields that need to be complete. However for one of them I have used the drop down menu and I am unsure on how to retrieve the data. For the entry fields I just use.get() then paste them into the array.

    OPTIONS = [
    "What was my first pets name?",
    "What was your favorite food as a child?",
    "What was the make of your first car?",
    "What is your mother's maiden name?"
    ]

    variable = StringVar(fp_frame)
    variable.set(OPTIONS[0]) # default value

    w = OptionMenu(fp_frame, variable, *OPTIONS)
    w.place(x=660,y=425,width = 240, height = 28)

This is the code for my drop down menu.

Try looking at this . So use the following code:

str(combo.current())

Does this help?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM