Forum Archive

Anchors SafeAreaView xxx.close()

DavinE

@mikael i think that‘s a question for you ;)

I‘ve got this example code:
```
import ui
import console
from anchors import SafeAreaView

class root(SafeAreaView):
def init(self):
self.background_color = 'blue'
self.name = 'SafeAreaView'
self.add_subview(ui.Button(frame=(2,12,32,32),title='close',action=self.viewClose))

def viewClose(self, sender):
    if console.alert('Close View?','','Yes','No',hide_cancel_button=True) is 2:
        return
    self.close()

s = root()
s.present('fullscreen', hide_title_bar=True)
```

But this don‘t work with the SafeAreaView When i change this to ui.View it works fine..
But why ?

mikael

@DavinE, the way I could make the safearea work was not to have it as root view. When it is presented it creates another view that is the real root.

So, change to self.superview.close() and it works.

DavinE

So easy and i don‘t get it....
Thanks so much

mikael

@DavinE, no way to really know without looking at the code, sorry.

DavinE

@mikael no Problem you helped me out xD

@mikael is it possible to dissable the two Finger slide down function in fullscreen ?

mikael

@DavinE, yes. First pip install ui3. Then from ui3.gestures import disable_swipe_to_close.

The function expects the root view, so in terms of your code here, you could add this to the end:

disable_swipe_to_close(s.superview)

DavinE

@mikael it works very well, Thanks again

mikael

@DavinE, oh yes, you can alternatively replace the closing gesture with your own ”secret gesture”, for example a 5-finger tap:

from ui3.gestures import tap

tap(view, 'close', number_of_touches_required=5)

Not very convenient, but maybe handy if your regular closing option is borked.

DavinE

@mikael said:

Not very convenient, but maybe handy if your regular closing option is borked.

Then i close Pythonista xD
disable_swipe_to_close is perfect

but thanks for your ideas