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.
Anchors SafeAreaView xxx.close()
-
@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 toui.View
it works fine..
But why ? -
@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. -
So easy and i don‘t get it....
Thanks so much -
@DavinE, no way to really know without looking at the code, sorry.
-
-
@DavinE, yes. First
pip install ui3
. Thenfrom 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)
-
@mikael it works very well, Thanks again
-
@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.
-
@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 perfectbut thanks for your ideas