How can Brython wait for an image to load similarly to how Jquery/Javascript does before proceeding with execution?
In the above Brython code errors list is never appended to because img.bind('load', on_load)
does not block execution. How can I block execution before proceeding?
Feel free offer up suggestions or an alternative approach to dealing with waits/blocking in Brython.
error = []
img = html.IMG(src=blob)
document <= img
def on_load(event):
if img.height*img.width > 2:
errors.append(f"Image dimensions are too large.")
print(errors) # The above error does indeed exist in errors.
img.bind('load', on_load)
if errors:
print(errors) # errors is empty because this was declared as img.bind was running