Skip to content

Commit 600f339

Browse files
committed
Warning when Script is not found
1 parent a976f4d commit 600f339

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

modules/scripts.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -739,12 +739,17 @@ def init_field(title):
739739
def onload_script_visibility(params):
740740
title = params.get('Script', None)
741741
if title:
742-
title_index = self.titles.index(title)
743-
visibility = title_index == self.script_load_ctr
744-
self.script_load_ctr = (self.script_load_ctr + 1) % len(self.titles)
745-
return gr.update(visible=visibility)
746-
else:
747-
return gr.update(visible=False)
742+
try:
743+
title_index = self.titles.index(title)
744+
visibility = title_index == self.script_load_ctr
745+
self.script_load_ctr = (self.script_load_ctr + 1) % len(self.titles)
746+
return gr.update(visible=visibility)
747+
except ValueError:
748+
params['Script'] = None
749+
massage = f'Cannot find Script: "{title}"'
750+
print(massage)
751+
gr.Warning(massage)
752+
return gr.update(visible=False)
748753

749754
self.infotext_fields.append((dropdown, lambda x: gr.update(value=x.get('Script', 'None'))))
750755
self.infotext_fields.extend([(script.group, onload_script_visibility) for script in self.selectable_scripts])

0 commit comments

Comments
 (0)