Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Segmentation error with beta 340007 in ui.Image.from_data(...)
-
ui.Image.from_data(...) gives a segmentation error in
def pil2ui(self,imgIn): with io.BytesIO() as bIO: imgIn.save(bIO, 'PNG') imgOut = ui.Image.from_data(bIO.getvalue())
Or
o = ObjCClass('UIImage').systemImageNamed_('arrow.up')#.chevron.compact.down') UIImagePNGRepresentation = c.UIImagePNGRepresentation UIImagePNGRepresentation.restype = c_void_p UIImagePNGRepresentation.argtypes = [c_void_p] UIImage_data = nsdata_to_bytes(ObjCInstance(UIImagePNGRepresentation(o))) ui_image = ui.Image.from_data(UIImage_data)
Code is old and did work until new beta, 340006 and 340007
Workaround
imgOut = ui.Image.named('iob:alert_32') ObjCInstance(imgOut).initWithData_(bIO.getvalue()) #imgOut = ui.Image.from_data(bIO.getvalue())
And
ui_image = ui.Image.named('iob:alert_32') ObjCInstance(ui_image).initWithData_(UIImage_data) #ui_image = ui.Image.from_data(UIImage_data)