Skip to content

Commit

Permalink
Warning when Script is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
w-e-w committed Apr 9, 2024
1 parent a976f4d commit 600f339
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions modules/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,12 +739,17 @@ def init_field(title):
def onload_script_visibility(params):
title = params.get('Script', None)
if title:
title_index = self.titles.index(title)
visibility = title_index == self.script_load_ctr
self.script_load_ctr = (self.script_load_ctr + 1) % len(self.titles)
return gr.update(visible=visibility)
else:
return gr.update(visible=False)
try:
title_index = self.titles.index(title)
visibility = title_index == self.script_load_ctr
self.script_load_ctr = (self.script_load_ctr + 1) % len(self.titles)
return gr.update(visible=visibility)
except ValueError:
params['Script'] = None
massage = f'Cannot find Script: "{title}"'
print(massage)
gr.Warning(massage)
return gr.update(visible=False)

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

0 comments on commit 600f339

Please sign in to comment.