easygui icon indicating copy to clipboard operation
easygui copied to clipboard

Ability to fill entry boxes if user does not

Open robertlugg opened this issue 11 years ago • 0 comments

Original text from: http://all-you-need-is-tech.blogspot.com/2013/01/improving-easygui-for-python.html

Andrew S08 June, 2013 23:32 Thanks Robbie this is very useful for building GUIs that look decent without much effort. One question: I have a multenterbox where one field can be left blank; if left blank, the program will autogenerate a number for the user. I would like to update the onscreen field with this number without closing the window (remain inside the callback). How can this be achieved?

Reply Replies

Robbie Brook09 June, 2013 12:00 Hi Andrew, What you're asking to do is actually populate the values in easygui.multenterbox after you sent them. This feature isn't supported. I would go for a simple solution like:

import easygui_callback 
import random

def get_auto_value():
    # your logic here
    return random.random()
choices = ["name", "address", "auto-field"]
values= ['default-name','default-address','']
input= ''

while True:
    input = easygui_callback.multenterbox("auto field","generator", choices,values)
    if input == None: break
if input[2] == "":
    values= [input[0],input[1],get_auto_value()]
else:
    # save data somewhere or whatever
    pass

If you really have to work with callback, you can hack easygui_callback.multenterbox to send also 'values' list to callback and set it there. On return from callback, you'll need to set this value list into its matching widget.

robertlugg avatar Jan 07 '15 19:01 robertlugg