Fix for Image element not loading following a finalize.
This commit is contained in:
parent
85cef1713b
commit
23ce1bb6af
|
@ -1,6 +1,6 @@
|
||||||
#usr/bin/python3
|
#usr/bin/python3
|
||||||
|
|
||||||
version = __version__ = "0.35.1 Unreleased fix for Text element after Remi update"
|
version = __version__ = "0.35.2 Unreleased fix for Text element after Remi update, Image element not loading fixed"
|
||||||
|
|
||||||
port = 'PySimpleGUIWeb'
|
port = 'PySimpleGUIWeb'
|
||||||
|
|
||||||
|
@ -1425,8 +1425,8 @@ class Image(Element):
|
||||||
self.EnableEvents = enable_events
|
self.EnableEvents = enable_events
|
||||||
sz = (0,0) if size == (None, None) else size
|
sz = (0,0) if size == (None, None) else size
|
||||||
self.Widget = None #type: SuperImage
|
self.Widget = None #type: SuperImage
|
||||||
if data is None and filename is None:
|
# if data is None and filename is None: # it is OK to have no image specified when intially creating
|
||||||
print('* Warning... no image specified in Image Element! *')
|
# print('* Warning... no image specified in Image Element! *')
|
||||||
super().__init__(ELEM_TYPE_IMAGE, size=sz, background_color=background_color, pad=pad, key=key,
|
super().__init__(ELEM_TYPE_IMAGE, size=sz, background_color=background_color, pad=pad, key=key,
|
||||||
tooltip=tooltip, visible=visible)
|
tooltip=tooltip, visible=visible)
|
||||||
return
|
return
|
||||||
|
@ -1507,19 +1507,14 @@ class SuperImage(remi.gui.Image):
|
||||||
try:
|
try:
|
||||||
#here a base64 image is received
|
#here a base64 image is received
|
||||||
self.imagedata = base64.b64decode(file_path_name, validate=True)
|
self.imagedata = base64.b64decode(file_path_name, validate=True)
|
||||||
self.attributes['src'] = "/%s/get_image_data?update_index=%s" % (id(self), str(time.time()))
|
|
||||||
except binascii.Error:
|
except binascii.Error:
|
||||||
#here an image data is received (opencv image)
|
#here an image data is received (opencv / PIL / other image)
|
||||||
self.imagedata = file_path_name
|
self.imagedata = file_path_name
|
||||||
self.refresh()
|
self.attributes['src'] = "/%s/get_image_data?update_index=%s" % (id(self), str(time.time()))
|
||||||
self.refresh()
|
self.refresh()
|
||||||
else:
|
else:
|
||||||
#here a filename is received
|
#here a filename is received
|
||||||
self.attributes['src'] = remi.gui.load_resource(file_path_name)
|
self.attributes['src'] = remi.gui.load_resource(file_path_name)
|
||||||
"""print(f'***** Loading file = {file_path_name}')
|
|
||||||
self.mimetype, self.encoding = mimetypes.guess_type(file_path_name)
|
|
||||||
with open(file_path_name, 'rb') as f:
|
|
||||||
self.imagedata = f.read()"""
|
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
|
|
Loading…
Reference in New Issue