Here is a simple animation based on @JonB 's code. It uses latest update function (available in beta) instead of threads.
import ui import numpy as np import io from PIL import Image class Screen(ui.View): def __init__(self,w,h): self.width=w self.height=h self.S = np.zeros((w,h), dtype=np.uint8) self.offset = 0 self.S[self.offset:self.offset+20,:] = 255 img = Image.fromarray(self.S, 'L') self.B=io.BytesIO() img.save(self.B, format='PNG') self.update_interval = 1 def set_data(self): self.S[self.offset:(self.offset+20),:] = 0 self.offset = (self.offset+20)%self.width self.S[self.offset:self.offset+20,:] = 255 img = Image.fromarray(self.S, 'L') img.save(self.B, format='PNG') self.B.seek(0) def update(self): self.set_data() self.set_needs_display() def draw(self): ui.Image.from_data(self.B.getvalue()).draw() if __name__=='__main__': import time w=300 h=w s=Screen(w,h) s.present('sheet')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.