-
Notifications
You must be signed in to change notification settings - Fork 117
/
Copy pathmultienter_backspace.py
38 lines (30 loc) · 1007 Bytes
/
multienter_backspace.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
__author__ = 'Robert'
"""
from:
http://stackoverflow.com/questions/26200738/how-to-add-backspace-event-to-easygui-multenterbox-fileds
"""
import sys
sys.path.append('..')
from easygui import *
msg = "Enter name"
title = "New name"
fieldName = ['name']
newTitle= 'NewName'
fieldValue = [newTitle]
fieldValue = multenterbox(msg,title, fieldName,fieldValue)
# make sure that none of the fields were left blank
while 1: # do forever, until we find acceptable values and break out
if fieldValue == None:
break
errmsg = ""
# look for errors in the returned values
for i in range(len(fieldName)):
if fieldValue[i].strip() == "":
errmsg = errmsg + '"{}" is a required field.\n\n'.format(fieldName[i])
if errmsg == "":
# no problems found
print ("Reply was:", fieldValue)
break
else:
# show the box again, with the errmsg as the message
fieldValue = multenterbox(errmsg, title, fieldName, fieldValue)