Using Overlays
My first post to the forum.
Using the Overlay class successfully — added the decorator to the attach function as was mentioned.
@on_main_thread
def attach(self):
self.parent.addSubview_(self)
In my demo file, I have a main image overlay (resizable) and two auxilary image overlays (resizable). Each of the overlays could have any kind of UI elements; just showing images for proof of concept.
I have found that, for each overlay, the following statements must be in the order shown or else the overlay window will not resize.
ooo=Overlay(name='abc', content=vvv, parent=AppWindows.root())
ooo.content_view.border_width=2
vvv.content_mode=ui.CONTENT_SCALE_ASPECT_FIT
Here is my demo file; provide your own PNG files (foo.png and fooe.png).
from overlay import Overlay, AppWindows
from gestures import Gestures
import ui
if __name__=='__main__':
iv0=ui.ImageView(frame=(0,0,300,300))
iv0.image=ui.Image.named('test:Peppers')
iv0.name='OMAIN▪️'
iv1=ui.ImageView(frame=(0,0,200,200))
iv1.image=ui.Image.named('foo.png')
iv1.name='ICR▪️'
iv1.alpha=1
overlay1=Overlay(content=iv1,parent=AppWindows.root())
overlay1.content_view.border_width=2
iv1.border_width=1
iv1.content_mode=ui.CONTENT_SCALE_ASPECT_FIT
iv2=ui.ImageView(frame=(0,0,200,200))
iv2.image=ui.Image.named('fooe.png')
iv2.name='E▪️'
iv2.alpha=1
overlay2=Overlay(content=iv2,parent=AppWindows.root())
overlay2.content_view.border_width=2
iv2.border_width=1
iv2.content_mode=ui.CONTENT_SCALE_ASPECT_FIT
omain=Overlay(name='abc', content=iv0, parent=AppWindows.root())
omain.content_view.border_width=2
iv0.border_width=1
iv0.content_mode=ui.CONTENT_SCALE_ASPECT_FIT