catch float ValueError default -1
This commit is contained in:
parent
9d78d317ae
commit
4412398c4b
|
@ -51,7 +51,10 @@ class UiLoadsave:
|
||||||
if isinstance(x, gr.Textbox) and field == 'value': # due to an undersirable behavior of gr.Textbox, if you give it an int value instead of str, everything dies
|
if isinstance(x, gr.Textbox) and field == 'value': # due to an undersirable behavior of gr.Textbox, if you give it an int value instead of str, everything dies
|
||||||
saved_value = str(saved_value)
|
saved_value = str(saved_value)
|
||||||
elif isinstance(x, gr.Number) and field == 'value':
|
elif isinstance(x, gr.Number) and field == 'value':
|
||||||
|
try:
|
||||||
saved_value = float(saved_value)
|
saved_value = float(saved_value)
|
||||||
|
except ValueError:
|
||||||
|
saved_value = -1
|
||||||
|
|
||||||
setattr(obj, field, saved_value)
|
setattr(obj, field, saved_value)
|
||||||
if init_field is not None:
|
if init_field is not None:
|
||||||
|
|
Loading…
Reference in New Issue