Image Control
from mirmod.controls import Image Image()
from mirmod.controls import Image from mirmod import miranda import json import base64 @wob.init() def init(self): self.image_path = None @wob.receiver("value", "Image Path") def set_image(self, i): self.image_path = i @wob.receiver("state","image",control=Image(),hidden=True,connectable=False) def get_image(self,plotly_data): pass @wob.execute() def execute(self): # Load image from disk image = None if self.image_path: with open(self.image_path, "rb") as image_file: image = image_file.read() # generate base64 url image = "data:image/png;base64," + base64.b64encode(image).decode("utf-8") ecx = miranda.get_execution_context() ob = ecx.get_current_wob() sc = ecx.get_security_context() miranda.update_api( sc, ob, "RECEIVER", "image", "state", value=image, connectable=False, hidden=True ) miranda.notify_gui(sc, json.dumps({ "action": "update[VIEW]", "data": { "id": ob.id, "metadata_id" : ob.metadata_id } }))