Closed spyoungtech closed 8 years ago
. I was able to successfully modify the derived_boxes.py in the EasyGUI module to get the desired result of the X button always returning None, rather than False.
Where the boolbox function is defined I changed
if reply == choices[0]:
return True
else:
return False
TO:
if reply == choices[0]:
return True
elif reply == choices[1]:
return False
else:
return None
Now, I am able to distinguish when the "x" button is pressed, versus when "No" being selected in a ynbox (and any other box that wraps a boolbox)
confirmed. Good idea.
I finally got around to making this change.
The "x" button behavior could benefit from improvement/bug-fixing. The keyword argument "cancel_choice" should allow you to define a string, which will be returned if the user presses the "x" button.
The "x" button appears to be limited to returning either None or False.
Returning “False” is problematic for the following case and similar cases, where pressing “x” would be the same as clicking “No” which should not be the expected result of clicking “x”
In this case and similar cases, the 'else' case will never be caught. Ideally, boolboxes, ynboxes and the like should have the option to return some value other than True or False when the 'x' button is pressed.
AT THE VERY LEAST: pressing "x" should either ALWAYS return None for any kind of box, or you should be able to explicitly define what is returned when the x button is pressed.