I just wondered if someone could shed any light on the workings of the layout method in custom views for me. I get some inconsistent results. I am not sure if the inner workings of the code that's calling the layout method is doing some sort of smart caching of multiple events or not. If so it would explain why I don't get a one to one correlation to the views I resize to the number of times layout() is called. This might be a stupid question, especially if calls to layout are being cached. But is there anyway directly or indirectly to know in the layout() method what view had caused the event to be called. I realise, I could hide the subviews in the custom class and provide methods to manipulate them. Not really ideal though. I guess the other method would be to redraw all the subviews based on the new sizes.
Thanks
import ui
class test(ui.View):
def __init__(self):
self.background_color= 'white'
self.sv = ui.View(frame=(0,0,100,100))
self.sv.background_color ='red'
self.add_subview(self.sv)
self.sv2 = ui.View(frame=(0,100,100,100))
self.sv2.background_color ='yellow'
self.add_subview(self.sv2)
def layout(self):
print 'layout fired'
def will_close(self):
print 'closing view'
if __name__ == '__main__':
v = test()
v.sv.background_color = 'green'
print 'about to change sv2 height'
v.sv2.height = v.height / 2
print 'about to change sv width'
v.sv.width = v.width /2
v.present('sheet')
print 'about to change sv width '
v.sv2.width= 300
v.sv2.height = 100