File: multienter_backspace.py

package info (click to toggle)
python-easygui 0.98.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,492 kB
  • sloc: python: 3,242; makefile: 151; xml: 120
file content (38 lines) | stat: -rw-r--r-- 1,007 bytes parent folder | download | duplicates (3)
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)