Apr-05-2022, 04:59 AM
(This post was last modified: Apr-05-2022, 05:20 AM by Yoriz.
Edit Reason: Formatting
)
This is my full program: https://github.com/UnknownBob123/Card-Catalogue
The only thing that is not working as intended, is the minimum and maximum number a user can input, and it is between 1-25. If I input 0, and 26, nothing happens as it continues without stopping - it is supposed to prompt the same window again, asking it to input numbers between 1-25, until then the program won't proceed. I imagine my "validate_value" function is not being called, but I am not fully certain where or why this is happening. I'd appreciate a helping hand on this! :-)
Here is the part where the issue stated above is happening.
The only thing that is not working as intended, is the minimum and maximum number a user can input, and it is between 1-25. If I input 0, and 26, nothing happens as it continues without stopping - it is supposed to prompt the same window again, asking it to input numbers between 1-25, until then the program won't proceed. I imagine my "validate_value" function is not being called, but I am not fully certain where or why this is happening. I'd appreciate a helping hand on this! :-)
Here is the part where the issue stated above is happening.
def validate_value(value, item):
"""Input validation: Checks that the user has input a valid value.
"""
# If the user presses the Cancel button, function is called to
# confirm that the user wants to exit.
if value == None:
value = query_cancel()
# If the user presses the OK button without entering a value,
# the no_value() function is called to display an error message
# and get input.
while value == "":
value = no_value(item)
# The while loop checks that input is valid (from VALUE_MIN to
# VALUE_MAX), and if not an error message is displayed, and the
# user is prompted to re-enter the value.
while float(value) < VALUE_MIN or float(value) > VALUE_MAX:
msg = "Please enter a valid value for " + item + " (from " + str(VALUE_MIN) + " to " + str(VALUE_MAX) + ")."
title = "ERROR"
value = easygui.enterbox(msg, title)
# If the user pressed OK without entering a value, the function
# is called to display and error message and get input.
while value == "":
value = no_value(item)
# If the user presses the Cancel button, function is called to
# confirm that the user wants to exit.
if value == None:
value = query_cancel()
return (value)
