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.
Scene find out device orientation.
-
How can I find out device orientation? Should I use scene.gravity() to get gravity and then try to transform it into orientation?
-
Run this and then tap the X to close the scene... The results will be printed on the console.
import scene class MyScene(scene.Scene): def __init__(self): scene.run(self) def setup(self): # This will be called before the first frame is drawn. print(self.bounds, self.isLandscape(), self.scale(), scene.get_screen_scale()) def scale(self): _, _, x, y = self.bounds landscape = self.isLandscape() x /= 1024 if landscape else 768 y /= 768 if landscape else 1024 return scene.Point(x, y) def isLandscape(self): return self.bounds.w > self.bounds.h MyScene()