diff options
Diffstat (limited to 'modules/ui_loadsave.py')
-rw-r--r-- | modules/ui_loadsave.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/modules/ui_loadsave.py b/modules/ui_loadsave.py index 0052a5cc..9a40cf4f 100644 --- a/modules/ui_loadsave.py +++ b/modules/ui_loadsave.py @@ -8,7 +8,7 @@ from modules.ui_components import ToolButton class UiLoadsave:
- """allows saving and restorig default values for gradio components"""
+ """allows saving and restoring default values for gradio components"""
def __init__(self, filename):
self.filename = filename
@@ -48,6 +48,14 @@ class UiLoadsave: elif condition and not condition(saved_value):
pass
else:
+ if isinstance(x, gr.Textbox) and field == 'value': # due to an undesirable behavior of gr.Textbox, if you give it an int value instead of str, everything dies
+ saved_value = str(saved_value)
+ elif isinstance(x, gr.Number) and field == 'value':
+ try:
+ saved_value = float(saved_value)
+ except ValueError:
+ return
+
setattr(obj, field, saved_value)
if init_field is not None:
init_field(saved_value)
|