Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to fill entry boxes if user does not #42

Open
robertlugg opened this issue Jan 7, 2015 · 0 comments
Open

Ability to fill entry boxes if user does not #42

robertlugg opened this issue Jan 7, 2015 · 0 comments

Comments

@robertlugg
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant